java - Set custom subject for mail in log4j SMTPAppender -
i want every time message logged being sent mail, different subject should set. below log4j config smtpappender
log4j.appender.email=org.apache.log4j.net.smtpappender log4j.appender.email.smtphost=localhost log4j.appender.email.smtpport=25 log4j.appender.email.from="user@mydomain.com" log4j.appender.email.to="user@mydomain.com" log4j.appender.email.subject="test" log4j.appender.email.layout=org.apache.log4j.patternlayout log4j.appender.email.layout.conversionpattern=%d{yyyy-mm-dd hh:mm:ss} :: %-5p :: %c{1}:%l :: message :: %m%n
i know smtpappender should extended, can't find satisfactory info how can write class accept subject when log event triggered. example
logger.error("sample message");
for log message subject should accepted. how achieve this?
you're right, face reload properties issue. doubt work on concurrent system (2 errors raised @ same time). instead create dedicated service send emails without using log4j. way, should gain on robustness aspect.
Comments
Post a Comment