Logahawk Logo
Logahawk
Logging should be easy - Easy to code and easy to read
Listeners

Listeners are the last step in logging. Listeners receive formatted message, a Date, and a Severity from a Logger, construct the final message, and persist that message somewhere.

Listeners nominally follow the adapter pattern, adapting some storage mechanism for holding log messages. The most common use of Listeners is to wrap some other logging framework.

Listener implementations may use a MessageFormatter to simplify creating the final message from a Date, Severity, and string message created by various formatters.

Logahawk comes with a few Listener implementations in the core package:

Below are implementations for well-know logging libraries. This code is not part of the core package because they depend on external libraries. The code here is intended to be copied directly into your code and customized to your needs. (This code is also part of the sources package if you wish to download all of them at once.) There are additional Listener implementations included in the core package.

There are some simpler Listener implementations included with Logahawk. These can be used to help build a custom Listener, or to write to some non-standard storage system.

One good scenario would be to use a StreamListener with a CipherOutputStream to handle writing a log that may contain confidential information.

Listeners can also be used for more than just writing directly to a storage system. For example, the be used to control the flow of log messages. The FailSafeListener is designed to handle unreliable Listeners. The FailSafeListener takes two Listeners, a primary and a backup Listener. If the primary Listener throws an exception, the log message is logged to the backup Listener.