First of all, I use Idea, in tomcat 8, everything is normal. Replaced after 9, there have been garbled problem .
Before finding the real problem, I Baidu online more than N data, are all tried, but it will not work.
such as:
1, the system to modify the default configuration windows utf-8 encoded.
2, modify the default encoding of cmd
3, modify the tomcat conf / server.xml file. Add URIEncoding = "UTF-8"
4, the modified idea vm options: -Dfile.enconding = UTF-8
5, and modify the coding startup.bat tomcat bin directory under catalina.bat
Note: The above five, do not work.
6, directly modify the tomcat conf / logging.properties file .
添加:java.util.logging.ConsoleHandler.encoding = GBK
This method can be corrected tomcat start garbled problem. However, log4j program configuration, log, or garbled .
then. I put the log4j configuration file in:
Encoding = UTF-8 全部修改为 Encoding = GBK
然后,问题是解决了。 但这不是我想要的。 我希望,程序中所有文件的编码,都是UTF-8,保证程序的编码一致性。
Then I compared the tomcat8 and tomcat basic profile 9. Found conf / logging.properties configuration file has distinguished encoding.
Under tomcat9 conf / the logging.properties file
More than 5 xxxxx.org.apache.juli.AsyncFileHandler.encoding = UTF-8
And tomcat8 down, but did not.
Then, I put these org.apache.juli.AsyncFileHandler.encoding = UTF-8 all commented out.
The GBK also commented previously configured.
Restart tomcat. Console everything is normal.
Log4j modify the configuration file, to UTF-8. Everything is normal . ( The fact that when after the encoding in the conf / logging.properties file all removed,
log4j configuration file, UTF-8 / GBK can log normal output . )
Since then, the problem is solved.
Note: For the next tomcat 9, conf / logging.properties file configures the five encoding = UTF-8, why would result in garbled tomcat logs, as well as the program itself diary garbled. Not try to understand. (I guess, and windows should be the default encoding problem.)