idea控制台 tomcat输出 中文乱码的处理方法 亲测可用 整理如下

idea控制台 tomcat输出 中文乱码的处理方法 亲测可用 整理如下

IT小君   2020-10-24T13:43:26

网上找了一堆都没有,自己琢磨了一下:

网上一般处理方法

1、bin/idea64.exe.vmoptions和bin/idea.exe.vmoptions 添加 -Dfile.encoding=UTF-8 

2、打开 IDEA -> 点击顶部菜单【Help】 -> 【Edit Custom VM Options...】 添加 -Dfile.encoding=UTF-8

3、打开 IDEA->Run/Debug Configurations中设置Tomcat配置  VM options :-Dfile.encoding=UTF-8

        startup/connection 页签下 添加 JAVA_TOOL_OPTIONS :-Dfile.encoding=UTF-8

以上修改还是有点问题,Tomcat自己的输出内容可能不会再乱码了,但是应用自身的控制台输出可能还是会有问题。

继续  打开并检查 $TOMCAT_HOME/conf/logging.properties ,将如下文件UTF-8全部修改为GBK,重启tomcat

1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.maxDays = 90
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.maxDays = 90
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.maxDays = 90
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = UTF-8



分享到:
评论(0)