Oliver Matz created LOG4J2-3372:
-----------------------------------

             Summary: ConsoleAppender on Windows does not use platform default 
encoding
                 Key: LOG4J2-3372
                 URL: https://issues.apache.org/jira/browse/LOG4J2-3372
             Project: Log4j 2
          Issue Type: Bug
          Components: Appenders
    Affects Versions: 2.17.1
            Reporter: Oliver Matz


The attached example outputs a short string containing non-ascii characters 
("Schöner Spaß") both to System.out and via log4j2 to a ConsoleAppender with 
target SYSTEM_OUT.

When I run the example in my IDE, it outputs the string correctly both times, 
as expected

However, if I run the example in a console on my Windows Desktop (10.0), only 
the output to System.out is correct. The non-ascii-characters get broken in the 
output of log4j2.

I know that a workaround is to add {{charset="IBM850"}} in the 
{{PatternLayout}}, but this clearly caused problems if the application runs in 
a different environment.

I definitely expect that log4j uses the platform default encoding, just as 
System.out does, and this seems to be other peoples' expectation, too. See e.g. 
LOG4J2-2929, stating incorrectly that "Currently PatternLayout always uses the 
default charset if none is specified explicitly."




--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to