[ https://issues.apache.org/jira/browse/LOG4J2-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461785#comment-13461785 ]
Joern Huxhorn commented on LOG4J2-85: ------------------------------------- The evaluation/formatting of the message should be performed immediately before adding it as a String to the backend collection. This is a convenience feature for the user since a message pattern with placeholders is nicer to write than a list of concatenated strings, especially if being accustomed to it by writing the same patterns in log messages. Beside the added convenience this has a performance impact if the NDC is disabled entirely. In that case, no formatting would be performed at all. I implemented an NDC like that over at https://github.com/huxi/lilith/blob/master/logback/classic/src/main/java/de/huxhorn/lilith/logback/classic/SimpleNDCAdapter.java (It keeps the message pattern and arguments in separate ThreadLocals to prevent a classloader leak. That way only standard java classes are put into a ThreadLocal.) Pop (in your case) would always just return the formatted string. > Replace ThreadContext.push(String msg) with push(String msg, Object args...) > ---------------------------------------------------------------------------- > > Key: LOG4J2-85 > URL: https://issues.apache.org/jira/browse/LOG4J2-85 > Project: Log4j 2 > Issue Type: Improvement > Reporter: Joern Huxhorn > > Provide the option to use similar message formatting like the usual log > methods. The API is still alpha so we can safely replace the method. > If NDC functionality would be disabled (see LOG4J2-84) then message > formatting wouldn't be performed at all, thus being significantly faster than > always composing the message. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org