I occasionally receive emails with logs that have OFF level and no message when using <SMTP> with a filter and the setting -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector.
I believe the cause is that AsyncLoggerContextSelector uses RingBufferLogEvents, and when the filter matches these events are buffered by the SmtpManager and then cleared soon after by the RingBufferLogEventHandler. Once the SmtpManager's buffer has filled, the empty events are added to the email.
There is logic in SmtpManager.add(LogEvent) to copy the contents of mutable messages, and it might be appropriate to do the same for RingBufferLogEvents.
- links to