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 "Minglei Lee (JIRA)" <ji...@apache.org> on 2014/08/18 11:09:18 UTC

[jira] [Updated] (LOG4J2-783) PatternLayout's default charset should not be UTF-8

     [ https://issues.apache.org/jira/browse/LOG4J2-783?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Minglei Lee updated LOG4J2-783:
-------------------------------

    Description: 
According to log4j2's manual about PatternLayout's charset attribute, if the attribute is not specified, the default system Charset will be used.

But in my environemnt (Win8 Simplified Chinese + Tomcat 7), if the attribute is not specified, the Chinese words cannot display properly in console. If I add charset="UTF-8" to <Console>'s <PatternLayout> element, the error still exists. But if I modify it to charset="GBK", the problem can be resolved.

So I think, The default charset is UTF-8, not the default system Charset as the manual announced. I got the source file, and found it in PatternLayout's Builder inner class: 

private Charset charset = Charsets.UTF_8;

I modify it to:

private Charset charset = Charset.defaultCharset();

and remove the charset attribute in XML's <PatternLayout> element, the Chinese words can display properly as expected.

So, I think it may be a bug and reported it here.

Thanks!

  was:
According to log4j2's manual about PatternLayout's charset attribute, if the attribute is not specified, the default system Charset will be used.

But in my environemnt (Win8 Simplified Chinese + Tomcat 7), if the attribute is not specified, the Chinese words cannot display properly in console. If I add charset="UTF-8" to console's PatternLayout, the error still exists. But if I modify it to charset="GBK", the problem can be resolved.

So I think, The default charset is UTF-8, not the default system Charset as the manual announced. I got the source file, and found it in PatternLayout's Builder inner class: 

private Charset charset = Charsets.UTF_8;

I modify it to:

private Charset charset = Charset.defaultCharset();

and remove the charset attribute in XML's PatternLayout element, the Chinese words can display properly as expected.

So, I think it may be a bug and reported it here.

Thanks!


> PatternLayout's default charset should not be UTF-8
> ---------------------------------------------------
>
>                 Key: LOG4J2-783
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-783
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.1
>         Environment: Win8(Simplified Chinese), Tomcat 7
>            Reporter: Minglei Lee
>              Labels: charset, default
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> According to log4j2's manual about PatternLayout's charset attribute, if the attribute is not specified, the default system Charset will be used.
> But in my environemnt (Win8 Simplified Chinese + Tomcat 7), if the attribute is not specified, the Chinese words cannot display properly in console. If I add charset="UTF-8" to <Console>'s <PatternLayout> element, the error still exists. But if I modify it to charset="GBK", the problem can be resolved.
> So I think, The default charset is UTF-8, not the default system Charset as the manual announced. I got the source file, and found it in PatternLayout's Builder inner class: 
> private Charset charset = Charsets.UTF_8;
> I modify it to:
> private Charset charset = Charset.defaultCharset();
> and remove the charset attribute in XML's <PatternLayout> element, the Chinese words can display properly as expected.
> So, I think it may be a bug and reported it here.
> Thanks!



--
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