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>
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: