Matt Sicker created LOG4J2-1848: ----------------------------------- Summary: Add JSON encoding support to EncodingPatternConverter %encode{}. Key: LOG4J2-1848 URL: https://issues.apache.org/jira/browse/LOG4J2-1848 Project: Log4j 2 Issue Type: New Feature Components: Layouts Reporter: Matt Sicker Assignee: Matt Sicker
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: {noformat} 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". {noformat} -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org