spring boot logback日志显示时间差8小时,java时间与系统时间不一致

参考:https://blog.csdn.net/u014453475/article/details/100579856

 

 

官方文档:

The second parameter specifies a timezone. For example, the '%date{HH:mm:ss.SSS, Australia/Perth} would print the time in the time zone of Perth, Australia, the world's most isolated city. Note that in the absence of the timezone parameter, the default timezone of the host Java platform is used. If the specified timezone identifier is unknown or misspelled, the GMT timezone is assumed as dictated by the TimeZone.getTimeZone(String) method specification.

意思是可以在yyyy-MM-dd HH:mm:ss.SSS后面加一个指定的时区,用逗号分隔开。如yyyy-MM-dd HH:mm:ss.SSS,CTT

<property name="CONSOLE_LOG_PATTERN"
          value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS})
<property name="CONSOLE_LOG_PATTERN"
          value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS,CTT})

CTT为上海时间

参考资料:https://blog.csdn.net/baidu_38404101/article/details/102495885

========日志时间有问题,也可能是代码获取的到的时间就是有问题的==========

 

 

System.currentTimeMills获取到的时间不是系统的当前时区的时间

这时启动jar包的命令中添加时区参数
java -jar -Duser.timezone=GMT+08 xxx.jar

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值