You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Brandon (Jira)" <ji...@apache.org> on 2021/06/02 16:26:00 UTC
[jira] [Commented] (LOG4J2-2539) SMTPAppender displays empty
message for priorEvents in the email
[ https://issues.apache.org/jira/browse/LOG4J2-2539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17355848#comment-17355848 ]
Brandon commented on LOG4J2-2539:
---------------------------------
I had the same issue when using -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector with Disruptor lib. In the SMTP Appender I get a RingBufferLogEvent that gets added to the CyclicBuffer<LogEvent> buffer but later in the code a clear() is called on it. When this type gets added there is some logic to make other types immutable, Log4jLogEvent and MutableLogEvent but not RingBufferLogEvent. I added it in the add method so it looks like:
{code:java}
public void add(LogEvent event) {
if (event instanceof Log4jLogEvent && event.getMessage() instanceof ReusableMessage) {
((Log4jLogEvent) event).makeMessageImmutable();
} else if (event instanceof MutableLogEvent) {
event = ((MutableLogEvent) event).createMemento();
} else if (event instanceof RingBufferLogEvent) {
event = ((RingBufferLogEvent) event).createMemento();
}
buffer.add(event);
}
{code}
> SMTPAppender displays empty message for priorEvents in the email
> ----------------------------------------------------------------
>
> Key: LOG4J2-2539
> URL: https://issues.apache.org/jira/browse/LOG4J2-2539
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.11.1
> Environment: jvm: OpenJDK Runtime Environment 1.8.0_191-b12 OpenJDK 64-Bit Server VM)
> os: Linux (unknown) amd64 4.14.88-88.76.amzn2.x86_64
> container: Apache Tomcat/9.0.14
> Reporter: Anantha
> Priority: Major
> Attachments: log4j2_error_email.png
>
>
> Context entries display Level = Off and Logger = root, with no log message, instead of the actual log entry (see attachment), whereas console appender logs display the right message.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)