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

Enhance PatternLayout %X Format options

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.11.1
    • None
    • Layouts

    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

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

            Dates

              Created:
              Updated: