如何禁用特定附加程序的 LogLog

发布于 2024-09-24 10:42:36 字数 700 浏览 3 评论 0原文

现在我们有一个类似于...的附加程序

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离笑几人歌 2024-10-01 10:42:36

LogLog非常简单,它只是将错误写入System.err。您只能使用 LogLog.setQuietMo​​de(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文