IDEA通过Tomcat部署Servlet应用,日志输出乱码

一、问题描述

Java web项目,采用logback记录日志,使用tomcat做为启动容器,但是,当运行的时候,打印日志有很多中文乱码。网上参考了很多,但是总感觉没有详细明确的说法。

而且logback日志编码已经设置为UTF-8。

二、问题原因

Idea显示日志的编码,默认好像不是UTF-8,修改为UTF-8。同时Tomcat运行虚拟机VM的编码默认也不是UTF-8,所以也需要设置一下。

三、解决问题

1.设置IDEA显示编码为UTF-8

(1)Help-》Edit Custom VM Options...

(2)添加:-Dfile.encoding=UTF-8

2.设置tomcat运行编码是UTF-8

(1)打开配置

(2)添加:-Dfile.encoding=UTF-8


3.重启idea!【切记,一定要重启,否则不生效!】

4.重启之后结果


 
 
  1. JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@ 13cf8d53] will not be managed by Spring
  2. ==>  Preparing: SELECT area_id, area_name, area_desc, priority, create_time, last_edit_time FROM tb_area ORDER BY priority DESC 
  3. ==> Parameters: 
  4. <==    Columns: area_id, area_name, area_desc, priority, create_time, last_edit_time
  5. <==        Row: 1, 南天门, null, 3, null, null
  6. <==        Row: 2, 北天门, null, 2, null, null
  7. <==      Total: 2

四、参考

1.https://www.cnblogs.com/Wicher-lsl/p/11317390.html

2.https://blog.csdn.net/c5113620/article/details/96285449

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值