简体   繁体   English

是否有任何提供额外附加程序的 log4j 或 slf4j 附加程序框架

[英]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.虽然核心 log4j 和 slf4j 库附带了很多好东西,我可以自己构建,但我想知道是否有任何库附带有趣的附加程序。

Most appenders seem to be bridges providing some connectivity to a particular service such as emailing messages or updating the NT event log.大多数附加程序似乎是提供与特定服务(例如电子邮件消息或更新 NT 事件日志)的某些连接的桥梁。 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.我的一个想法是只记录来自 http 请求的消息,这些请求在处理过程中抛出一些异常。 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.自然,这种 appender 需要一些东西来帮助控制它。

BufferControl {
   FLUSH_NOW, // flush everything now in the buffer
   FLLUSH, // flush everything when BufferingLogger.commit() is called.
   CLEAR, // clear everything before
   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.将需要 controller 来标记日志记录事务的开始,以及是否根据某些条件清除或刷新。

Naturally some smarts would be necessary to reset the buffer and so on.自然地,需要一些聪明才智来重置缓冲区等等。

Logback is slf4j implementation providing lots of configurable appenders. Logback 是 slf4j 实现,提供了许多可配置的 appender。 http://logback.qos.ch/ 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详细信息: http://logback.qos.ch/manual/filters.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM