Christian Bindseil created LOG4J2-302:
-----------------------------------------

             Summary: NDCPatternConverter broken in beta7
                 Key: LOG4J2-302
                 URL: https://issues.apache.org/jira/browse/LOG4J2-302
             Project: Log4j 2
          Issue Type: Bug
          Components: Layouts
    Affects Versions: 2.0-beta7
            Reporter: Christian Bindseil


After an upgrade from version 2.0-beta4 to beta7 the NDCPatternConverter writes 
an object-ID instead of the content of the NDC-stack. 

We are using an pattern with "[%0.50x]". In beta4 the resulting output looks 
like "[cbi@CE03178]" which means username and machine. Now in beta7 it looks 
like "[logging.log4j.spi.MutableThreadContextStack@875ef7]".

I analysed the issue in NDCPatternConverter.format(...) method, where 
event.getContextStack() is called and the result is passed to 
StringBuilder.append(...), which means, that the toString()-method will be 
invoked. 
In beta4 getContextStack() returns an instance of ImmutableStack. This class 
inherits its toString() method from AbstractList, where the elements of the 
collection will be formatted human-readable. 
Now in beta7 there comes an instance of MutableThreadContextStack which isn't 
derived from AbstractList but implements the Collection-Interface. The 
toString() method comes from Object and returns the name of the class and an 
object-ID instead of the context of the unterlying stack/collection.

In my opinion you just need to copy or derive the toString() method from 
AbstractList to solve this issue. Thank you in advance!


--
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to