[
https://issues.apache.org/jira/browse/LOG4J2-1452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15356489#comment-15356489
]
Remko Popma commented on LOG4J2-1452:
-------------------------------------
Notes on how to address this:
* The implementation of {{logger.traceEntry("some \{}", "message");}} in
AbstractLogger internally (in its {{entryMsg()}} method) delegates to the
MessageFactory to create a Message which is then wrapped in a FlowMessage by
the FlowMessageFactory. If the MessageFactory creates ReusableMessages, we get
the above problem. We can solve this by avoiding the MessageFactory and
explicitly constructing the appropriate Message implementation class in the
{{entryMsg}} method.
* Users may explicitly construct a Message with the Logger's MessageFactory as
in the above example, resulting in the same problem. FlowMessageFactory will
need to "unpack" any ReusableMessages that it is passed and construct an
immutable Message from it. Documentation needs to be updated to say that
ReusableMessages should not be passed as the parameter to
{{traceEntry(Message)}}.
> Reusable messages break flow tracing logic
> ------------------------------------------
>
> Key: LOG4J2-1452
> URL: https://issues.apache.org/jira/browse/LOG4J2-1452
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.6, 2.6.1
> Reporter: Mikael Ståldal
> Assignee: Remko Popma
> Fix For: 2.6.2
>
>
> Flow tracing assumes that you can save an instance of {{EntryMessage}} across
> a method, but if you log something else within that method and reusable
> messages are in effect (as they are by default since 2.6), this does not
> always work properly.
> This code illustrate the issue:
> {code}
> EntryMessage entryMessage =
> logger.traceEntry(logger.getMessageFactory().newMessage("the entry"));
> logger.info("something else");
> logger.traceExit(entryMessage);
> {code}
> It works as expected if you remove the middle {{logger.info()}}, but with it
> the exit message gets messed up.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]