开发者

emailing from log4j

开发者 https://www.devze.com 2023-01-28 07:17 出处:网络
I currently email errors logged through log4j with: <appender name=\"email\" class=\"org.apache.log4j.net.SMTPAppender\">

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消