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

Add JSON encoding support to EncodingPatternConverter %encode{}.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.8.2
    • Layouts
    • None

    Description

      The existing implementation of EncodingPatternConverter is for escaping output for HTML specifically. This pattern converter should be extended to allow multiple types of encoding. The existing HTML behavior should be the default, but an optional second parameter should be added to allow specifying a different format to encode for.

      For JSON, encoding would require the following:

         The representation of strings is similar to conventions used in the C
         family of programming languages.  A string begins and ends with
         quotation marks.  All Unicode characters may be placed within the
         quotation marks except for the characters that must be escaped:
         quotation mark, reverse solidus, and the control characters (U+0000
         through U+001F).
      
         Any character may be escaped.  If the character is in the Basic
         Multilingual Plane (U+0000 through U+FFFF), then it may be
         represented as a six-character sequence: a reverse solidus, followed
         by the lowercase letter u, followed by four hexadecimal digits that
         encode the character's code point.  The hexadecimal letters A though
         F can be upper or lowercase.  So, for example, a string containing
         only a single reverse solidus character may be represented as
         "\u005C".
      
         Alternatively, there are two-character sequence escape
         representations of some popular characters.  So, for example, a
         string containing only a single reverse solidus character may be
         represented more compactly as "\\".
      
         To escape an extended character that is not in the Basic Multilingual
         Plane, the character is represented as a twelve-character sequence,
         encoding the UTF-16 surrogate pair.  So, for example, a string
         containing only the G clef character (U+1D11E) may be represented as
         "\uD834\uDD1E".
      

      Attachments

        Issue Links

          Activity

            People

              mattsicker Matt Sicker
              mattsicker Matt Sicker
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: