Elasticsearch doesn't start inside a UTF-8 cmd.exe on Windows Server 2016 Core instance.
This can be easily reproduced on a Windows 10 instance by manually changing the codepage to 65001:
1) Open a cmd.exe with default code page set to 850. Elasticsearch starts fine.
2) Change the code page to 65001 (Unicode) via the chcp command. Start Elasticsearch again. This will throw the exception below:
2017-07-31 13:51:03,209 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)
The exception is thrown by log4j and already reported as ticket:
https://issues.apache.org/jira/browse/LOG4J2-1888
Till this is fixed, I'm wondering if someone knows a work-around? I tried to set the character set via the log4j2.properties file, but no luck yet.
Yes, a workaround would be to set the JVM options: -Dsun.stdout.encoding=UTF-8 and -Dsun.stderr.encoding=UTF-8.
@jasontedor Should this be documented in the installation guide?
@dadoonet For now I don't think so, this is the first report we have seen of this issue; if we see repeated reports, comments, or 馃憤 on this issue then we consider it (I also want to wait and see how the upstream issue is handled).
Note that the upstream issue is fixed starting in Log4j 2.9.0 which is included in Elasticsearch 5.6.0 and future pre-releases of Elasticsearch 6.0.0 (it missed 6.0.0-beta2). At this time, the need for the above workaround should go away. I will verify this later today.
I verified that with Log4j 2.9.0, this issue does go away in the following sense: the node will now successfully start with Log4j falling back to UTF-8 as opposed to before where it blew up when it did not know what to do with the charset cp65001. However, Log4j dumps a low-level stack trace to the console. This is a low-level dump in the sense that it does not go through the status logger so we have no chance to capture this and keep it off the console.
1.set utf-8:
1.cmd
2.chcp 65001
3.close
2.set default code:
1.cmd
2.chcp 936
3.right-hand button -> option -> discard old copies
Most helpful comment
@dadoonet For now I don't think so, this is the first report we have seen of this issue; if we see repeated reports, comments, or 馃憤 on this issue then we consider it (I also want to wait and see how the upstream issue is handled).