NutzCN Logo
问答 为什么我的log4j中文乱码
发布于 2816天前 作者 LovelyIsJustice 2493 次浏览 复制 上一个帖子 下一个帖子
标签:

log4j.properties

log4j.rootLogger=debug,console,file
log4j.appender.console.encoding=UTF-8
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%-5p] %d %30c %m%n

log4j.appender.file.encoding=UTF-8
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern='-'yyyy-MM-dd
log4j.appender.file.File=${SealServices.root}/logs/log.log
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%-5p] %d %30c %m%n
log4j.logger.org.quartz.core.QuartzSchedulerThread=info

控制台

[INFO ] 2017-03-01 10:59:20,942 com.kmia.fams.utils.HttpRequest Transfer-Encoding--->[chunked]
[INFO ] 2017-03-01 10:59:20,942 com.kmia.fams.utils.HttpRequest null--->[HTTP/1.1 200]
[INFO ] 2017-03-01 10:59:20,942 com.kmia.fams.utils.HttpRequest Cache-Control--->[no-cache]
[INFO ] 2017-03-01 10:59:20,942 com.kmia.fams.utils.HttpRequest Date--->[Wed, 01 Mar 2017 03:00:02 GMT]
[INFO ] 2017-03-01 10:59:20,942 com.kmia.fams.utils.HttpRequest Content-Type--->[text/plain;charset=UTF-8]
[INFO ] 2017-03-01 10:59:20,943 com.kmia.fams.service.OrgService 鑾峰彇鎴愬姛orgEmp1
[INFO ] 2017-03-01 10:59:20,943   org.nutz.mvc.impl.NutLoading Nutz.Mvc[nutz] is up in 2513ms
[2017-03-01 10:59:20,976] Artifact KMIA_FAMS:war exploded: Artifact is deployed successfully
[2017-03-01 10:59:20,976] Artifact KMIA_FAMS:war exploded: Deploy took 5,562 milliseconds
01-Mar-2017 10:59:25.355 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory D:\apache-tomcat-8.5.9\webapps\manager
01-Mar-2017 10:59:25.385 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\apache-tomcat-8.5.9\webapps\manager has finished in 29 ms
[DEBUG] 2017-03-01 11:00:00,010       org.nutz.ioc.impl.NutIoc Get 'updateBaseInfo'<class com.kmia.fams.job.UpdateBaseInfo>
[DEBUG] 2017-03-01 11:00:00,011       org.nutz.ioc.impl.NutIoc 	 >> Load definition name=updateBaseInfo
[DEBUG] 2017-03-01 11:00:00,011 org.nutz.ioc.loader.combo.ComboIocLoader Found IocObject(updateBaseInfo) in AnnotationIocLoader(packages=[com.kmia.fams])
[DEBUG] 2017-03-01 11:00:00,011       org.nutz.ioc.impl.NutIoc 	 >> Make...'updateBaseInfo'<class com.kmia.fams.job.UpdateBaseInfo>
[DEBUG] 2017-03-01 11:00:00,012 org.nutz.ioc.aop.impl.DefaultMirrorFactory Load class com.kmia.fams.job.UpdateBaseInfo without AOP
[DEBUG] 2017-03-01 11:00:00,012 org.nutz.ioc.impl.ScopeContext Save object 'updateBaseInfo' to [app] 
[DEBUG] 2017-03-01 11:00:00,013       org.nutz.ioc.impl.NutIoc Get 'orgService'<class com.kmia.fams.service.OrgService>
[DEBUG] 2017-03-01 11:00:00,016    org.quartz.core.JobRunShell Calling execute on job DEFAULT.com.kmia.fams.job.UpdateBaseInfo
[INFO ] 2017-03-01 11:00:00,017 com.kmia.fams.job.UpdateBaseInfo 浠诲姟UpdateBaseInfo鎵ц浜�
[DEBUG] 2017-03-01 11:00:00,017 org.nutz.dao.impl.sql.run.NutDaoExecutor SELECT * FROM FAMS_BASIC_INFO  ORDER BY id DESC  
[INFO ] 2017-03-01 11:00:00,027 com.kmia.fams.utils.HttpRequest Transfer-Encoding--->[chunked]
[INFO ] 2017-03-01 11:00:00,027 com.kmia.fams.utils.HttpRequest null--->[HTTP/1.1 200]
[INFO ] 2017-03-01 11:00:00,027 com.kmia.fams.utils.HttpRequest Cache-Control--->[no-cache]
[INFO ] 2017-03-01 11:00:00,027 com.kmia.fams.utils.HttpRequest Date--->[Wed, 01 Mar 2017 03:00:42 GMT]
[INFO ] 2017-03-01 11:00:00,027 com.kmia.fams.utils.HttpRequest Content-Type--->[text/plain;charset=UTF-8]
[INFO ] 2017-03-01 11:00:00,028 com.kmia.fams.service.OrgService 鑾峰彇鎴愬姛organization1
[INFO ] 2017-03-01 11:00:00,031 com.kmia.fams.utils.HttpRequest Transfer-Encoding--->[chunked]
[INFO ] 2017-03-01 11:00:00,031 com.kmia.fams.utils.HttpRequest null--->[HTTP/1.1 200]
[INFO ] 2017-03-01 11:00:00,031 com.kmia.fams.utils.HttpRequest Cache-Control--->[no-cache]
[INFO ] 2017-03-01 11:00:00,031 com.kmia.fams.utils.HttpRequest Date--->[Wed, 01 Mar 2017 03:00:42 GMT]
[INFO ] 2017-03-01 11:00:00,031 com.kmia.fams.utils.HttpRequest Content-Type--->[text/plain;charset=UTF-8]
[INFO ] 2017-03-01 11:00:00,032 com.kmia.fams.service.OrgService 鑾峰彇鎴愬姛orgEmp1

但是我的工程还有idea,encode都设置的是utf-8
为什么一直都是乱码呢?
求大神相助

2 回复

idea的console选一下utf8

console的编码是不是在界面右下角 我的已经是UTF-8了
而且不是所有中文都是乱码,只有在log4j输出的日志中文才乱码
输出的日子文件不乱码,但是控制台是乱码
@wendal

添加回复
请先登陆
回到顶部