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

Remko Popma edited comment on LOG4J2-255 at 5/16/13 6:58 AM:
-------------------------------------------------------------

Gary, you are describing the different use case of sharing log files between 
environments that use different encodings.
Fair enough, you need to tell the recipient what encoding the file is in.

In the use case I am describing, writing and reading is happening on the same 
machine.
If you write UTF-8 bytes to the Console, the Console will interpret these bytes 
as being in the platform encoding.

This works for English text because the platform encoding (I assume US-ASCII) 
is a subset of UTF-8, so you cannot test this on your machine.
But for Japanese text, if you take UTF-8 bytes for "日本語" and you interpret 
these bytes as MS932 (the platform encoding for Japanese Windows), you end up 
with scrambled text.
                
      was (Author: rem...@yahoo.com):
    Gary, you are describing the different use case of sharing log files 
between environments that use different encodings.
Fair enough, you need to tell the recipient what encoding the file is in.

In the use case I am describing, writing and reading is happening on the same 
machine.
If you write UTF-8 bytes to the Console, the Console will interpret these bytes 
as being in the platform encoding.

This works for English text because the platform encoding (I assume US-ASCII) 
is a subset of UTF-8, so you cannot test this on your machine.
But for Japanese text, if you take UTF-8 bytes for "日本語" and you interpret 
these bytes as MS932, you end up with scrambled text.
                  
> 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 is the log4j2.xml configuration:
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="warn">
>     <appenders>
>         <Console name="Console" target="SYSTEM_OUT">
>             <PatternLayout>
>                 <pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
>                 </pattern>
>             </PatternLayout>
>         </Console>
>         <File name="tracelog" fileName="trace-log.txt" immediateFlush="true" 
> append="false">
>             <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level 
> %logger{36} - %msg%n"/>
>         </File>
>     </appenders>
>     
>     <loggers>
>         <root level="trace">
>             <appender-ref ref="Console"/>
>             <appender-ref ref="tracelog"/>
>         </root>
>     </loggers>
> </configuration>

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