[
https://issues.apache.org/jira/browse/LOG4J2-1888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16106315#comment-16106315
]
md_5 commented on LOG4J2-1888:
------------------------------
Can confirm,
{code}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util">
<Appenders>
<Console name="WINDOWS_COMPAT" target="SYSTEM_OUT"></Console>
<Queue name="TerminalConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
</Queue>
<RollingRandomAccessFile name="File" fileName="logs/latest.log"
filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<OnStartupTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="1000"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="info">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY"
onMismatch="NEUTRAL" />
</filters>
<AppenderRef ref="WINDOWS_COMPAT"/>
<AppenderRef ref="File"/>
<AppenderRef ref="TerminalConsole"/>
</Root>
</Loggers>
</Configuration>
{code}
Happens when users use 'chcp 65001' to attempt a UTF-8 console in cmd.exe on
Windows.
I'm not sure what magic Java does when getting the output charset, but it uses
Windows-1252 for System.out even when the properties are set to cp65001 which
is why you don't see the error there.
> Log4j throws a java.nio.charset.UnsupportedCharsetException: cp65001
> --------------------------------------------------------------------
>
> Key: LOG4J2-1888
> URL: https://issues.apache.org/jira/browse/LOG4J2-1888
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.8.2
> Reporter: Misagh Moayyed
>
> Running a Java spring boot web application using a "java -jar" type of
> command with a pretty vanilla log4j2.xml file in it, I see the following
> error.
> {code}
> 2017-04-24 11:47:45,338 main ERROR Unable to inject fields into builder class
> for plugin type class org.apache.logging.log4j.core.appender.ConsoleAppender,
> element Console. java.nio.charset.UnsupportedCharsetException: cp65001
> at java.nio.charset.Charset.forName(Charset.java:531)
> at
> org.apache.logging.log4j.util.PropertiesUtil.getCharsetProperty(PropertiesUtil.java:146)
> at
> org.apache.logging.log4j.util.PropertiesUtil.getCharsetProperty(PropertiesUtil.java:134)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Target.getCharset(ConsoleAppender.java:85)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Target$1.getDefaultCharset(ConsoleAppender.java:71)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:218)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:185)
> at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:952)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:892)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:884)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:508)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:232)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:244)
> {code}
> I am running the "run" command on Windows 10 64x inside a ConEmu console. If
> I switch to Babun, then I don't see the error.
> This may not exactly be a "bug", but it would be great to not crash the app
> and fallback to a more accepting encoding perhaps.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)