Create PrimaryLogHandler.

It wraps a StreamHandler and throws a specific exception when the
stream cannot be written to.
Create and register listener that handles primary log write exceptions