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

Remko Popma commented on LOG4J2-255:
------------------------------------

Gary, thanks for reviewing the changes!

I did not fully understand your comments, let me know if I interpreted them 
correctly:
1) Charsets.getSupportedCharset should not return the platform default 
encoding, but UTF-8, because then the method will return a constant value.
2) The JUnit tests I wrote will fail for some developers 
3) The JUnit tests are not complete, an additional test is needed that actually 
writes to a file

Let me reply to these one by one.

1)
I don't know about the spec for this method, but going on current usage,
getSupportedCharset is used by all Layouts to (a) either validate a specified 
encoding - may replace this if unsupported, or (b) provide a default encoding 
if the user did not specify an encoding in the layout configuration. I guess 
(b) is most common.

The key point is that to prevent scrambled messages in the log file, the 
encoding of the source code with the call to Logger.log must match the encoding 
used to write the message to the log file. If getSupportedCharset always 
returns a constant UTF-8 then the log file will always contain scrambled 
messages unless the user saves their source code in UTF-8. 

Most developers save their source code in the platform encoding. Eclipse and 
NetBeans save source code in the platform encoding by default (sorry, I don't 
know about IntelliJ). Hence the Layouts should use the platform encoding when 
converting chars to bytes (unless an encoding is specified in the config).

2)
I believe this is a misunderstanding. KOI8-R is an encoding for Russian, not 
JP. It is actually part of the Basic Encodings and included in lib/rt.jar
This test should work for everyone.

3)
You are probably right. 

                
> Multi-byte character strings are scrambled in log output
> --------------------------------------------------------
>
>                 Key: LOG4J2-255
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-255
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders, Core
>    Affects Versions: 2.0-beta6
>            Reporter: Remko Popma
>            Assignee: Remko Popma
>            Priority: Blocker
>             Fix For: 2.0-beta7
>
>
> When I tried to log a Japanese string the output was scrambled in both the 
> Console and a log file.
> For example,
> logger.warn("日本語テスト"); // (Japanese test)
> came out as
> 15:07:00.184 [main] WARN  test.JapaneseTest - 譌・譛ャ隱槭ユ繧ケ繝?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to