Are there any log4j or slf4j Appender frameworks that provide additional appenders
While the core log4j and slf4j libraries come with a lot of good stuff, and i could build my own, but i was wondering if there are any libraries that ship with interesting appenders.
Most appenders seem to be bridges providing some connectivity to a particular service such as emailing messages or updating the NT event log. I am thinking of loggers that are more abstract and not middleware like, but equally useful to watchers of a live system.
CRAZY IDEA OF AN APPENDER I THINK MIGHT BE USEFUL
Logging is often useful but it can be a pain due to the shear volume of messages that really arent necessary because the associated request completed successfully. One idea ive had is wouldnt ie be useful to only log messages from http requests that throw some exception during processing. If the request did not fail then nothing would be added to the log. Naturally this sort of appender would require something to help control it.
BufferControl {
FLUSH_NOW, // flush everything now in the buffer
FLLUSH, // flush everything when BufferingLogger.commit() is called.
CLEAR, // clear everything befor开发者_Python百科e
CLEAR_ALL; /// all past and future messages are ignored
IGNORE_AFTER; // ignore messages after this event.
IGNORE_BEFORE, // ignore messages before
CONTINUE, // just continue...
etc etc..
}
// implements could tell the bufferingappender to log messages because some exception was thrown etc.
LoggingEventWatcher {
BufferControl look(LoggingEvent, BufferingAppender);
}
// every logging event is passed to the logging event watcher which
BufferingAppender {
start();
reset(); // throw away everything in the buffer
commit(); // use returned BufferControl to flush or reset etc.
flush(); // unconditionally flush all messages now.
}
Imagine if one could log all messages only if a certain exception was logged. A controller would be needed to mark the start of a logging transaction, and whether to clear or flush depending on some condition.
Naturally some smarts would be necessary to reset the buffer and so on.
Logback is slf4j implementation providing lots of configurable appenders. http://logback.qos.ch/
It provides Context based logging, events, and extensive filtering of log events. You can with little effort extend basic filters with your own to suit your needs.
Details here: http://logback.qos.ch/manual/filters.html
精彩评论