java - Log4j2 smtp appender doesn't work for root logger -
i'm using log4j2.2 in app. i'd receive email when there error in application.
so configured smtp appender:
<smtp name="mailer" subject="ecall logs" to="${receipients}" from="${from}" smtphost="${smtphost}" smtpport="${smtpport}" smtpprotocol="${smtpprotocol}" smtpusername="${smtpuser}" smtppassword="${smtppassword}" smtpdebug="true" buffersize="200" ignoreexceptions="false"> </smtp>
and added root logger:
<root level="error"> <appender-ref ref="console" /> <appender-ref ref="asyncfile" /> <appender-ref ref="mailer" /> </root>
unfortunately configuration never receive email when there errors in app. in fact i've others custom loggers:
<logger level="info" name="org.flywaydb" additivity="false"> <appender-ref ref="console" /> <appender-ref ref="asyncfile" /> </logger>
which right way configure smtp logger whole application (catch errors packages) 100 lines of buffers in order see happened before/after error?
you may have found bug. smtp appender should send email when receives error-level log event. try include "buffersize" events (from trace warn) preceded error.
i don't think smpt appender requires preceding non-error events, can try this:
<root level="trace"> <appender-ref ref="console" level="error"/> <appender-ref ref="asyncfile" level="error"/> <appender-ref ref="mailer" level="trace"/> </root>
if problem persists please raise ticket on log4j2 jira issue tracker.
Comments
Post a Comment