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

Add support for values in MDC in JSONLayout KeyValuePairs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 2.10.0
    • None
    • Layouts

    Description

      The new KeyValuePair within JSONLayout as implemented for https://issues.apache.org/jira/browse/LOG4J2-1694 doesn't provide support for MDC stored values.

      In PatternLayout one can do something like this:

      <Pattern>%d{ISO8601}{UTC} %d{Z}{UTC} [CID:%X{conversation-id}] [%t] %-5p %c{1.} - %m%n</Pattern>
      

      But it seems that

      <KeyValuePair key="CID" value="%X{conversation-id}"/>
      

      or even

      <KeyValuePair key="CID" value="${conversation-id}"/>
      

      doesn't work.

      Variable replacement doesn't appear to read from the MDC.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dankirkd Daniel Kirkdorffer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: