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

Enhance PatternLayout %X Format options

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.11.1
    • Fix Version/s: None
    • Component/s: Layouts
    • Labels:

      Description

      One can print out the full MDC key value pair set in a PatternLayout, but can only do so in a format that looks like this: {key1=val1, key2=val2}

      We've been using PatternLayout as a replacement for JSONLayout, due to certain limitations with JSONLayout, but the format for %X key/value lists do not conform to valid JSON syntax, and attempts to convert it using %replace run up against regex limitations (or overly complex regex) for dealing with edge cases (such as values that themselves contain curly brackets).

      What would be nice is a means to customize the list output, i.e. to use : instead of =, and to double quote the keys and values, to produce valid JSON.  I assume similar options for other formats, such as XML would be helpful too.

      Since we already have %enc for proper encoding, having this key/value list in various formats that %enc supports, would make sense.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dankirkd Daniel Kirkdorffer
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: