I configured log4j SMTPAppender to send emails to me on errors. It works, but I have problem with non ASCII data. Configuration uses HTMLLayout and their documentation states:
Appenders using this layout should have their encoding set to UTF-8 or UTF-16, otherwise events containing non ASCII characters could result in corrupted log files.
My log files must contains UTF-8 data, but I can’t find where I can set encoding for appender. Here is appender configuration:
<appender name="MAIL" class="org.apache.log4j.net.SMTPAppender">
<param name="BufferSize" value="25" />
<param name="SMTPHost" value="localhost" />
<param name="From" value="myapp@...com" />
<param name="Threshold" value="error" />
<param name="To" value="me@gmail.com" />
<param name="Subject" value="Error Occurred" />
<param name="LocationInfo" value="true"/>
<param name="encoding" value="UTF-8" />
<!-- <param name="Encoding" value="UTF-8"/> -->
<layout class="org.apache.log4j.HTMLLayout">
</layout>
</appender>
When application runs I got:
log4j:WARN No such property [encoding] in org.apache.log4j.net.SMTPAppender
According to the code of the latest SMTPAppender (1.2.15), not only there no setEncoding, but the encoding does not even mentioned there.
Do you actually see issues with it? If so, why not inheriting from SMTPAppender or provide your own implementation?