You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2017/03/12 19:02:04 UTC

[jira] [Commented] (LOG4J2-1848) Add JSON encoding support to EncodingPatternConverter %encode{}.

    [ https://issues.apache.org/jira/browse/LOG4J2-1848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15906649#comment-15906649 ] 

ASF subversion and git services commented on LOG4J2-1848:
---------------------------------------------------------

Commit 07e91be6b1e96fc96709f1a5051c7421ccaa6041 in logging-log4j2's branch refs/heads/master from [~jvz]
[ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=07e91be ]

[LOG4J2-1848]: Add JSON encoding support to %enc

This adds an escape format option to EncodingPatternConverter to allow
for either HTML or JSON as the escape format. This converter can be
useful for creating custom JSON layouts via a pattern layout.


> 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-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org