Bhavani Sheri created LOG4J2-3594: ------------------------------------- Summary: ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console:java.nio.charset.IllegalCharsetNameException: "file:/C:\test\log4j2.xml" Key: LOG4J2-3594 URL: https://issues.apache.org/jira/browse/LOG4J2-3594 Project: Log4j 2 Issue Type: Bug Affects Versions: 2.18.0 Environment: windows Reporter: Bhavani Sheri
I have a test.bat file where I set -Dlog4j2.configurationFile to point to a valid log4j2.xml. This log4j2.xml has a console appender which is resulting in below exception. java.nio.charset.IllegalCharsetNameException:file:/C:\test\log4j2.xml at java.base/java.nio.charset.Charset.checkName(Charset.java:308) at java.base/java.nio.charset.Charset.lookup2(Charset.java:482) at java.base/java.nio.charset.Charset.lookup(Charset.java:462) at java.base/java.nio.charset.Charset.isSupported(Charset.java:503) at org.apache.logging.log4j.util.PropertiesUtil.getCharsetProperty(PropertiesUtil.java:215) Please note that same script file works fine in linux machine and I see this issue just in windows. If I replace log4j 2.18.0 with log4j 2.17.1 then I dont see any errors. After some basic debugging I got to know that normalized map under PropertiesUtil is not getting populated properly. All the properties in the map have log4j2.xml file path as value and thus the encoding property value in that map is set to log4j2.xml file path which is resulting in above exception. Below is my configuration for log4j2.xml. <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Appenders> <Console name="CONSOLE" target="SYSTEM_OUT"> <PatternLayout pattern="%-5p | %d\{yyyy-MM-dd HH:mm:ss} | [%t] %C\{2} (%F:%L) - %m%n" /> </Console> </Appenders> <Loggers> <Logger name="com.test.package" level="WARN" additivity="false"> <AppenderRef ref="CONSOLE" /> </Logger> <Root level="WARN"> <AppenderRef ref="CONSOLE" /> </Root> </Loggers> </Configuration> -- This message was sent by Atlassian Jira (v8.20.10#820010)