Reputation: 35
I have a log4J.xml SMTPAppender configuration as follows:
<appender name="MAIL" class="org.apache.log4j.net.SMTPAppender">
<param name="Threshold" value="ERROR"/>
<param name="EvaluatorClass" value="fi.reaktor.log4j.emailthrottle.ErrorEmailThrottle"/>
<param name="BufferSize" value="512"/>
<param name="SMTPHost" value="xxxx"/>
<param name="SMTPPort" value="25"/>
<param name="From" value="xxxx"/>
<param name="To" value="xxx"/>
<param name="Subject" value="xxx"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd/MM/yyyy HH:mm:ss} [%-5p] [%c{1}: %M] %m%n"/>
</layout>
</appender>
I use an EvaluatorClass that I was advised on the link: https://github.com/reaktor/log4j-email-throttle
On the page, it was marked that you can change the default configuration in a log4j.properties file:
fi.reaktor.log4j.emailthrottle.throttleIfUnderSecs=60
fi.reaktor.log4j.emailthrottle.emailIntervalInSecs=900
fi.reaktor.log4j.emailthrottle.normalAfterSecs=3600
Unfortunately, I do not see how to apply it in my Log4j.xml file.
Upvotes: 1
Views: 363
Reputation: 775
The page you refer to says:
You can change default values by setting these System properties So you can't put those settings in log4j config file.
You either need to set those properties on the command line where you start jvm, with "-D" flag:
java -Dfi.reaktor.log4j.emailthrottle.throttleIfUnderSecs=60 \ -Dfi.reaktor.log4j.emailthrottle.emailIntervalInSecs=900 \ -Dfi.reaktor.log4j.emailthrottle.normalAfterSecs=3600
or set it from your code programmatically:
System.setProperty("fi.reaktor.log4j.emailthrottle.throttleIfUnderSecs", "60");
System.setProperty("fi.reaktor.log4j.emailthrottle.emailIntervalInSecs", "900");
System.setProperty("fi.reaktor.log4j.emailthrottle.normalAfterSecs", "3600");
Upvotes: 1