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 "Gary Gregory (JIRA)" <ji...@apache.org> on 2014/06/25 14:34:24 UTC

[jira] [Comment Edited] (LOG4J2-682) Special characters (tab) in PatternLayout

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

Gary Gregory edited comment on LOG4J2-682 at 6/25/14 12:32 PM:
---------------------------------------------------------------

Serendipity!

See the discussion on the user ML: https://mail-archives.apache.org/mod_mbox/logging-log4j-user/201406.mbox/%3CCAKnbemWoAXryn7UH=qMmwr=ad24La1+qv+cyO9OXxCCCJAGV_g@mail.gmail.com%3E


was (Author: garydgregory):
Serendipity!

See the discussion on the ML: https://mail-archives.apache.org/mod_mbox/logging-log4j-user/201406.mbox/%3CCAKnbemWoAXryn7UH=qMmwr=ad24La1+qv+cyO9OXxCCCJAGV_g@mail.gmail.com%3E

> Special characters (tab) in PatternLayout
> -----------------------------------------
>
>                 Key: LOG4J2-682
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-682
>             Project: Log4j 2
>          Issue Type: Improvement
>    Affects Versions: 2.0-rc1
>            Reporter: Scott Harrington
>            Priority: Minor
>         Attachments: log4j-r1604932-specialchars.patch
>
>
> I upgraded a log4j 1.2 layout pattern containing "\t" to log4j 2:
> {noformat}
>    <param name="ConversionPattern" value="%{ISO8601}\t%m%n"/>
>    ...becomes...
>    <PatternLayout pattern="%{ISO8601}\t%m%n"/>
> {noformat}
> The resulting output contained "\t" instead of the expected tab character.
> It seems the old {{DOMConfigurator}} applied {{OptionConverter.convertSpecialChars}} to the "value" attribute of every "param" element.
> We can't convert special characters quite as broadly anymore because it would break things like the "%replace" pattern. I considered various conversion points including the {{PatternLayout}} constructor, in {{XmlConfiguration.processAttributes}}, or in {{AbstractPluginVisitor.convert}}.
> In fact, {{PatternLayout.setConversionPattern}} actually did {{convertSpecialChars}} even though the constructor did not.
> It seems the best place to replace the 'special chars' is now in {{LiteralPatternConverter}} (see my patch). I added a test to {{PatternLayoutTest}} to demonstrate.
> I studied all the other plugin attributes and couldn't find any others where special characters might be useful, except perhaps the {{ColumnConfig}} "pattern" attribute, which happens to use PatternLayout so it now supports the special character escapes as well.
> Side note: {{PatternLayout.setConversionPattern}} was not storing the new value in the conversionPattern field since it was final. I've made it non-final (see patch) so we can store it there, just in case anyone ever calls {{getConversionPattern}} (not likely).



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org