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

Gary Gregory edited comment on LOG4J2-2053 at 10/9/17 5:54 PM:
---------------------------------------------------------------

This mapping is not quite right. Please the current version in git master here: 
{{log4j-api/src/main/resources/Log4j-charsets.properties}}

For example, the charset {{ibm-912_P100-1995}} is provided by ICU but the page 
https://msdn.microsoft.com/en-us/en-en/library/windows/desktop/dd317756(v=vs.85).aspx
 maps {{28592}} to {{iso-8859-2}} which exists in the Oracle JRE. This lets you 
create the mapping without depending on ICU.

If you really want to map to UTF-7, then yes, you will need to depend on ICU, 
in which case, we can consider adding an optional dependency to ICU4J so that 
tests will pass when testing the default mapping file. Or we can relax the test.

Also run this test when you update the mapping: 
{{org.apache.logging.log4j.util.Log4jCharsetsPropertiesTest}}

To check if a charset SOME_NAME can be loaded run 
{{org.apache.logging.log4j.util.CharsetForNameMain SOME_NAME}} 

To update the property file, either attach a patch file here in unified diff 
format. Alternatively, (and better IMO), you can create a PR on GitHub 
https://github.com/apache/log4j


was (Author: garydgregory):
This mapping is not quite right. Please the current version in git master here: 
{{log4j-api/src/main/resources/Log4j-charsets.properties}}

For example, the charset {{ibm-912_P100-1995}} is provided by ICU but the page 
https://msdn.microsoft.com/en-us/en-en/library/windows/desktop/dd317756(v=vs.85).aspx
 maps {{28592}} to {{iso-8859-2}} which exists in the Oracle JRE. This lets you 
create the mapping without depending on ICU.

Also run this test when you update the mapping: 
{{org.apache.logging.log4j.util.Log4jCharsetsPropertiesTest}}

To check if a charset SOME_NAME can be loaded run 
{{org.apache.logging.log4j.util.CharsetForNameMain SOME_NAME}} 

To update the property file, either attach a patch file here in unified diff 
format. Alternatively, (and better IMO), you can create a PR on GitHub 
https://github.com/apache/log4j

> Exception java.nio.charset.UnsupportedCharsetException: cp65001 in 2.9.0
> ------------------------------------------------------------------------
>
>                 Key: LOG4J2-2053
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2053
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.9.0, 2.9.1
>         Environment: Windows 10x64 1607 German
> Java JDK 1.8.0_144 (JAVA_TOOL_OPTIONS=-Dsun.jnu.encoding=UTF8 
> -Dfile.encoding=UTF8 -Ds=0)
> Fitnesse 20161106
> Log4j 2.9.0
> Executing from command line, switching to chcp 65001
>            Reporter: Frank Steudle
>            Priority: Minor
>
> Today I updated my fitnesse project to use the 2.9.0 versions of log4-core 
> and log4j-api. Now I am encountering the exception 
> java.nio.charset.UnsupportedCharsetException: cp65001. 
> However, my project is running well. Logging seems to work anyway.
> According to Issue 1888, there was a similar bug, which was fixed in 2.9.0: 
> [https://issues.apache.org/jira/browse/LOG4J2-1888]. I commented it, but 
> didn't get an answer until now.
> I am using ISO-8859-1 on my Eclipse computer to store the files. But the 
> execution environment is plain UTF-8. Therefore I am using those parameters 
> to run my fitnesse project:
> * -Dsun.jnu.encoding=UTF8: handed over as JAVA_TOOL_OPTIONS
> * -Dfile.encoding=UTF8: handed over as JAVA_TOOL_OPTIONS
> * chcp 65001: to switch the Windows console encoding to UTF8
> Here is the exception, which is thrown: 
> {code:java}
> C:\Users\admin\Desktop\RabbitDevInstall\Testtool>java -jar 
> RunRabbitRun-2.0-SNAPSHOT-jar-with-dependencies.jar start ./Resources
> Picked up JAVA_TOOL_OPTIONS: -Dsun.jnu.encoding=UTF8 -Dfile.encoding=UTF8 
> -Ds=0
> Unable to get Charset 'sun.stdout.encoding', using default UTF-8
> java.nio.charset.UnsupportedCharsetException: cp65001
>         at java.nio.charset.Charset.forName(Unknown Source)
>         at 
> org.apache.logging.log4j.util.PropertiesUtil.getCharsetProperty(PropertiesUtil.java:172)
>         at 
> org.apache.logging.log4j.core.appender.ConsoleAppender$Target.getCharset(ConsoleAppender.java:89)
>         at 
> org.apache.logging.log4j.core.appender.ConsoleAppender$Target$1.getDefaultCharset(ConsoleAppender.java:74)
>         at 
> org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:222)
>         at 
> org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:189)
>         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:958)
>         at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
>         at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
>         at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
>         at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
>         at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
>         at 
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
>         at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
>         at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
>         at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
>         at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
>         at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>         at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
>         at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:551)
>         at de.duerr.fitnesse.RunRabbitRun.<clinit>(RunRabbitRun.java:24)
> 11:37:19.176 [main] DEBUG de.duerr.fitnesse.RunRabbitRun - Passed over first 
> parameter: start
> 11:37:19.192 [main] DEBUG de.duerr.fitnesse.RunRabbitRun - Passed over 
> Fitnesse directory: ./Resources
> 11:37:19.192 [main] DEBUG de.duerr.fitnesse.RunRabbitRun - The parameters 
> handed over to Fitnesse: -d
> 11:37:19.192 [main] DEBUG de.duerr.fitnesse.RunRabbitRun - The parameters 
> handed over to Fitnesse: ./Resources
> 11:37:19.192 [main] DEBUG de.duerr.fitnesse.RunRabbitRun - The parameters 
> handed over to Fitnesse: -r
> 11:37:19.192 [main] DEBUG de.duerr.fitnesse.RunRabbitRun - The parameters 
> handed over to Fitnesse: FitNesseRoot
> Sep 20, 2017 11:37:19 AM fitnesse.ConfigurationParameter loadProperties
> INFORMATION: No configuration file found 
> (C:\Users\admin\Desktop\RabbitDevInstall\Testtool\Resources\plugins.properties)
> Bootstrapping FitNesse, the fully integrated standalone wiki and acceptance 
> testing framework.
> root page: fitnesse.wiki.fs.WikiFilePage: FitNesseRoot
> logger: none
> authenticator: fitnesse.authentication.PromiscuousAuthenticator
> page factory: fitnesse.html.template.PageFactory
> page theme: bootstrap
> Starting FitNesse on port: 80
> {code}
> Here is my log4j configuration file:
> {code:xml}
> <?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"/>
>     </Console>
>     
>     <RollingFile name="RollingFile" fileName="logs/rrr.log"
>                  
> filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
>       <PatternLayout>
>         <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
>       </PatternLayout>
>       <Policies>
>         <TimeBasedTriggeringPolicy />
>         <OnStartupTriggeringPolicy />
>         <SizeBasedTriggeringPolicy size="20 MB"/>
>       </Policies>
>     </RollingFile>
>     
>   </Appenders>
>   <Loggers>
>     <Root level="all">
>       <AppenderRef ref="RollingFile"/>
>       <AppenderRef ref="Console"/>
>     </Root>
>   </Loggers>
> </Configuration>
> {code}
> And here is my starting script:
> {code:java}
> SET RRR_RESOURCES=.
> SET JAVA_TOOL_OPTIONS=-Dsun.jnu.encoding=UTF8 -Dfile.encoding=UTF8 -Ds=0
> chcp 65001
> java -version
> java -XshowSettings
> java -jar ${project.artifactId}-${project.version}-jar-with-dependencies.jar 
> start ./Resources
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to