I'm using Logback 1.2.11 with Java 17 on Windows 10. I'm using the following logback.xml
:
<configuration>
<property scope="context" name="COLORIZER_COLORS" value="boldred@,boldyellow@,boldcyan@,@,@" />
<conversionRule conversionWord="colorize" converterClass="org.tuxdude.logback.extensions.LogColorizer" />
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
<target>System.err</target>
<withJansi>true</withJansi>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%colorize(%level)] %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDERR" />
</root>
</configuration>
If in my code I use System.out.println("é")
or System.err.println("é")
, I see an é
(U+00E9, a small letter e with acute accent) on the console as expected. However if I log through Logback (via SLF4J), it shows a Θ
character (U+0398, a Greek capital letter theta) on the screen. This happens whether I use <target>System.out</target>
or <target>System.err</target>
in my logback.xml
file.
By default the PatternLoutEncoder
for ConsoleAppender
should be using the system default encoding. (See LogBack default charset for LayoutWrappingEncoder? for extensive discussion.) The Windows 10 console encoding in my locale should be Windows-1252 (or in Powershell, ISO-8859-1). The Θ character doesn't even appear in either of those charsets.
Why is Logback printing a Θ
character to the standard output when it should be printing an é
character? More generally, why isn't Logback using the default encoding when printing to System.out
or System.err
?