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

NDCPatternConverter broken in beta7

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-beta7
    • 2.0-beta8
    • Layouts
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rpopma Remko Popma
            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

                Slack

                  Issue deployment