
<p style="font-size: medium; white-space: normal;"> <span style="text-indent: 2em; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); font-family: 微软雅黑, "Microsoft YaHei"; box-sizing: border-box;">一天一个关于测试知识点,5分钟内讲解你最关心的</span><span style="box-sizing: border-box;">软件测试</span><span style="text-indent: 2em; box-sizing: border-box; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); font-family: 微软雅黑, "Microsoft YaHei";">问题,今天就接着来谈谈关于软件测试中的“<strong><span style="box-sizing: border-box;">Tomcat日志乱码了怎么处理?</span></strong>”。</span></p><p style="font-size: medium; white-space: normal; text-align: center;"><span style="text-indent: 2em; box-sizing: border-box; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); font-family: 微软雅黑, "Microsoft YaHei";"><img style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG13045V3.jpg" title="Tomcat日志乱码了怎么处理?(图1)" alt="Tomcat日志乱码了怎么处理?(图1)"/></span></p><p style="font-size: medium; white-space: normal;"> <strong>【前言】</strong></p><p style="font-size: medium; white-space: normal;"> tomacat日志有三个地方,分别是Output(控制台)、Tomcat Localhost Log(tomcat本地日志)、Tomcat Catalina Log。</p><p style="font-size: medium; white-space: normal;"> 启动日志和大部分报错日志、普通日志都在output打印;有些错误日志,在Tomcat Localhost Log。</p><p style="font-size: medium; white-space: normal;"> 三个日志显示区,都可能出现乱码现象。</p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图2)" alt="Tomcat日志乱码了怎么处理?(图2)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG1311R92.png"/></p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图3)" alt="Tomcat日志乱码了怎么处理?(图3)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG1311RR.png"/></p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图4)" alt="Tomcat日志乱码了怎么处理?(图4)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG1311Q21.png"/></p><p style="font-size: medium; white-space: normal;"> <strong><span style="color: rgb(192, 0, 0);"> 1、解决方案一:</span></strong></p><p style="font-size: medium; white-space: normal;"> 首先,找到本地tomcat的conf目录下的logging.properties,这个文件中有5个编码的位置</p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图5)" alt="Tomcat日志乱码了怎么处理?(图5)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG1313D52.png"/></p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图6)" alt="Tomcat日志乱码了怎么处理?(图6)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png"/></p><p style="font-size: medium; white-space: normal;"> 1)对于控制台output报错的情况,将下图位置的编码格式,改成gbk</p><p style="font-size: medium; white-space: normal; text-align: center;"><img style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png" title="Tomcat日志乱码了怎么处理?(图7)" alt="Tomcat日志乱码了怎么处理?(图7)"/></p><p style="font-size: medium; white-space: normal;"> 2)Tomcat Locathost Log和Tomcat Catalina Log乱码的情况,解决方法和上面一样,只是修改的位置不同,修改下图位置</p><p style="font-size: medium; white-space: normal; text-align: center;"><img style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG1315A15.png" title="Tomcat日志乱码了怎么处理?(图8)" alt="Tomcat日志乱码了怎么处理?(图8)"/></p><p style="font-size: medium; white-space: normal;"> 最后,重启idea乱码就解决了。</p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图9)" alt="Tomcat日志乱码了怎么处理?(图9)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG13205C5.png"/></p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图10)" alt="Tomcat日志乱码了怎么处理?(图10)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png"/></p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图11)" alt="Tomcat日志乱码了怎么处理?(图11)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png"/></p><p style="font-size: medium; white-space: normal;"> <span style="color: rgb(192, 0, 0);"><strong> 2、解决方案二:</strong></span></p><p style="font-size: medium; white-space: normal;"> 点开HELP下的Edit Custom Properties…,在这个文件的最后添加</p><blockquote style="white-space: normal;"><p style="font-size: medium;"> -Dfile.encoding=UTF-8</p></blockquote><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图12)" alt="Tomcat日志乱码了怎么处理?(图12)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png"/></p><p style="white-space: normal; text-align: center;"><img title="Tomcat日志乱码了怎么处理?(图13)" alt="Tomcat日志乱码了怎么处理?(图13)" style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG13553N6.png"/></p><p style="font-size: medium; white-space: normal;"> 重启idea就好了。</p><p style="font-size: medium; white-space: normal;"> <span style="color: rgb(192, 0, 0);"><strong>3、解决方案三:</strong></span></p><p style="font-size: medium; white-space: normal;"> 1)打开tomcat配置页面,修改配置项VM options,输入</p><blockquote style="white-space: normal;"><p style="font-size: medium;"> -Dfile.encoding=UTF-8</p></blockquote><p style="font-size: medium; white-space: normal;"> 重启tomcat,查看乱码问题是否解决。</p><p style="font-size: medium; white-space: normal;"> 2)(如果依然乱码)打开IntelliJ IDEA本地安装目录中bin文件夹下的idea.exe.vmoptions和idea64.exe.vmoptions这两个文件</p><p style="font-size: medium; white-space: normal; text-align: center;"><img style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png" title="Tomcat日志乱码了怎么处理?(图14)" alt="Tomcat日志乱码了怎么处理?(图14)"/></p><p style="font-size: medium; white-space: normal;"> 分别在这两个文件内容的末尾添加-Dfile.encoding=UTF-8</p><p style="font-size: medium; white-space: normal; text-align: center;"><img style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png" title="Tomcat日志乱码了怎么处理?(图15)" alt="Tomcat日志乱码了怎么处理?(图15)"/></p><p style="font-size: medium; white-space: normal;"> 3)打开IntelliJ IDEA>File>Setting>Editor>File Encodings,将Global Encoding、Project Encoding、Default encodeing for properties files这三项都设置成UTF-8。</p><p style="font-size: medium; white-space: normal; text-align: center;"><img style="max-width:100%!important;height:auto!important;" src="http://www.chuansinfo.com/uploads/ueditor//5-220ZG.png" title="Tomcat日志乱码了怎么处理?(图16)" alt="Tomcat日志乱码了怎么处理?(图16)"/></p><p style="font-size: medium; white-space: normal;"> 4)重启Idea,查看乱码问题是否解决。</p>
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/176991.html