Tomcat控制台乱码解决方法

本地使用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
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\hong\.IntelliJIdea2018.2\system\tomcat\Tomcat_9_0_0_M17_dfac\conf\logging.properties
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53135,suspend=y,server=n
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:C:\Users\hong\.IntelliJIdea2018.2\system\captureAgent\debugger-agent.jar=file:/C:/Users/hong/AppData/Local/Temp/capture3095.props
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
22-Jan-2019 14:10:19.104 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
...

一共做了三件事:

1. 修改Tomcat配置文件,增加UTF-8编码

更改Tomcatconf文件夹下的service.xml配置,增加URIEncoding="UTF-8",具体如下:

发现启动情况仍无改变

2. 更改idea配置,设置编码为UTF-8

打开Setting,搜索File Encoding,修改配置如下图:

Tomcat控制台乱码解决方法_第1张图片
image

发现启动情况仍无改变

3. 修改tomcat的conf下的logging.properties中的参数

java.util.logging.ConsoleHandler.encoding = UTF-8

改为

java.util.logging.ConsoleHandler.encoding = GBK

ok了。

转自:https://www.jianshu.com/p/4a09e464f440

你可能感兴趣的:(Tomcat控制台乱码解决方法)