log4j2附录SMTP:如何在参数期间限制邮件的最大邮件数?
我使用log4j2迁移我的应用程序,我想知道如何在参数期间限制最大邮件数量
:每小时只触发一个邮件,无论使用log4j1捕获的错误数量,
我都使用特定的触发螺丝,但是triggeringeventeventevaluator triggeringeventevaluator班级似乎不再存在
<triggeringPolicy class="com.xerox.xgs.log4j.appender.triggeringEventEvaluator.DelayedSMTPAppenderTriggerEvaluator">
<param name="period" value="60000" />
</triggeringPolicy>
I migrate my application with log4j2 and I would like know how to limit the max number of mail during a parametric period
For example : only one mail per hour triggered regardless of the number of error catched
With Log4j1 I use a specific triggeringPolicy for that but TriggeringEventEvaluator class seem to be no longer exist
<triggeringPolicy class="com.xerox.xgs.log4j.appender.triggeringEventEvaluator.DelayedSMTPAppenderTriggerEvaluator">
<param name="period" value="60000" />
</triggeringPolicy>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在log4j2中,您可以在
smtpappender
上使用过滤器:发送电子邮件的每条通过Appender的过滤器发送的电子邮件(cf. javadoc )。过滤器拒绝的消息将作为上下文添加到电子邮件中(最多BufferSize
消息)。虽然默认过滤器仅允许
错误
消息要通过,但您可以使用burstfilter
限制电子邮件的金额。如果您想要
错误
消息以触发电子邮件,并且可以使用两个连续电子邮件之间的至少一个小时的间隔:In Log4j2 you can use filters on your
SMTPAppender
: an e-mail is sent for every message that passes the appender's filter (cf. javadoc). Messages denied by the filter are added to the e-mail as context (up tobufferSize
messages).While the default filter allows only
ERROR
messages to pass through, you can use aBurstFilter
to limit the amount of e-mails.If you want
ERROR
messages to trigger e-mails and at least an hour interval between two consecutive e-mails you can use: