I've configured an SMTPAppender into my Java app.
<appender name="AdministratorEmail" class="org.apache.log4j.net.SMTPAppender">
<param name="Threshold" value="info" />
<param name="BufferSize" value="512" />
<param name="SMTPHost" value="smtp.sss.intranet" />
<param name="From" value="adminEbookMaker@sss.intranet" />
<param name="To" value="user@sss.it" />
<param name="Subject" value="errors" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}]%n%n%-5p%n%n%c%n%n%m%n%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="info" />
<param name="LevelMax" value="fatal" />
</filter>
</appender>
I receive only the ERROR log type and not the INFO type! I changed the LevelMin but nothing, I inserted the Thresold, but nothing!
Does someone have any kind of suggestion?
The SMTPAppender by design only logs ERROR and above messages. This level cannot be affected by properties. The documentation for the appended states:
See: Class SMTPAppender
The fact that you are seeing INFO messages only after the first ERROR is due to the bufferSize property which shows the 'n' most recent log lines before the error to give context to the error.
Further research on this shows that there is an implementation of the required interface for TriggerEventEvaluator in the 'extras companion'
This can be downloaded from: Apache Download Mirrors
If you include this in your project you can then add the following to your SMTPAppender definition in log4j.xml (note the properties format is not supported!)