Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-302

NDCPatternConverter broken in beta7

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta7
    • Fix Version/s: 2.0-beta8
    • Component/s: Layouts
    • Labels:
      None

      Description

      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!

        Attachments

          Activity

            People

            • Assignee:
              remkop@yahoo.com Remko Popma
              Reporter:
              cgcb1 Christian Bindseil
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.25h
                0.25h
                Remaining:
                Remaining Estimate - 0.25h
                0.25h
                Logged:
                Time Spent - Not Specified
                Not Specified