如何禁用特定附加程序的 LogLog
现在我们有一个类似于...的附加程序
<appender name="email" class="org.apache.log4j.net.SMTPAppender">
当附加程序无法发送邮件时,我们会在文件(和收件箱,由于我们的日志记录的性质)中收到多行...
[2010 Sep 21 01:00:47] ERROR (FixSession.java:453) - log4j:ERROR Error occured while sending e-mail notification.
是否有一种方法仅记录一次或禁用仅此附加程序的内部日志记录?
注意:已经尝试过 errorHandler,似乎 SMTPAppender 使用 LogLog 而不是给定的处理程序...源位于 http://logging.apache.org/log4j/1.2/xref/org/apache/log4j/net/SMTPAppender.html
Right now we have an appender similar to...
<appender name="email" class="org.apache.log4j.net.SMTPAppender">
When the appender fails to send a mail, we get multiple lines of this in our file (and inboxes, due to nature of our logging)...
[2010 Sep 21 01:00:47] ERROR (FixSession.java:453) - log4j:ERROR Error occured while sending e-mail notification.
Would there be a way to only log once or disable internal logging for this appender only?
Note: already tried errorHandler, it seems the SMTPAppender uses LogLog rather than a given handler... source at http://logging.apache.org/log4j/1.2/xref/org/apache/log4j/net/SMTPAppender.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
LogLog非常简单,它只是将错误写入System.err。您只能使用 LogLog.setQuietMode(true) 完全关闭它。
也许您唯一的出路是基于 SNMPTAppender 创建自己的附加程序,然后添加您自己的错误处理。不过,这应该不会太难。
LogLog is very simplistic, it simply writes errors to System.err. You can only turn it off completely using LogLog.setQuietMode(true)
Probably the only way out for you is to create your own appender, based on SNMPTAppender and then add your own error handling. This shouldn't be too difficult, though.