配置好log4j.properties 文件
log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=C:/logs/wang.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.appender.R.Encoding=utf-8
不要忘了最下面的 log4j.appender.R.Encoding=utf-8
在这里加上 -Dfile.encoding=UTF-8
在系统用户文件夹下 C:\Users\wangzeyu.IntelliJIdea2019.3\config
找到idea64.exe.vmoptions
在最下面添加 -Dfile.encoding=UTF-8
在idea的根目录 bin目录下 找到idea64.exe.vmoptions 和 idea.exe.vmoptions
在最下面添加 -Dfile.encoding=UTF-8
在tomcat的安装目录D:\Tomcat\apache-tomcat-8.5.31\conf
找到 logging.properties 文件
最后一行添加
java.util.logging.ConsoleHandler.encoding = UTF-8