Tomcat有时会出现日志输出乱码的问题,如
Connected to the target VM, address: '127.0.0.1:53135', transport: 'socket'
22-Jan-2019 14:10:19.099 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.37
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Dec 12 2018 12:07:02 UTC
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.37.0
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 10
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.0
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_121\jre
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_121-b13
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\hong\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_0_M17_dfac
22-Jan-2019 14:10:19.103 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: D:\Program Files\tomcat8.5.37
这里的原因可能是多种多样,这里记录下常用的修复方式,可以按照顺序依次尝试修复该问题。
-
在
Idea Tomcat
配置中添加VM Options: -Dfile.encoding=UTF-8
-
检查
File->Settings->Editor->File Encodings
-
修改
Tomcat
下的配置文件conf/logging.properties
网友评论