emailing from log4j
I currently email errors logged through log4j with:
<appender name="email" class="org.apache.log4j.net.SMTPAppender">
<param name="SMTPHost" value="localhost"/>
<开发者_StackOverflow中文版param name="From" value="notifications@mydomain.com"/>
<param name="To" value="me@mydomain.com"/>
<param name="Subject" value="Error from mydomain.com"/>
</appender>
works great, but I'd really like to email me occasionally from a particular log file. This other log file, I also want even the INFO events that are logged. How do I do that? If I try to setup another emailAppender, or just use this emailAppender, nothing gets emailed because there seems to be a filter on ERROR or worse events. So I tried adding a LevelRangeFilter:
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="INFO"/>
<param name="LevelMax" value="FATAL"/>
</filter>
But it has no effect on an SMTPAppender :(.
From the javadoc it looks like this appender uses a super special TriggeringEventEvaluator as a filtering mechanism. You can probably fix this by creating your appender with an evaluator that always returns true. I'm not sure though.
精彩评论