日志4J;如何使用 ConversionPattern 确保时间戳始终在 GMT 中? [英] Log4J; how to ensure timestamps are always in GMT using ConversionPattern?

查看:19
本文介绍了日志4J;如何使用 ConversionPattern 确保时间戳始终在 GMT 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确保我的 log4j 使用的所有时间戳都是 GMT?

How can I ensure that all timestamps that my log4j is using, are in GMT?

我尝试了以下方法,但它在时间戳中打印GMT"

I have tried the following but it prints "GMT" inside the timestamp

log4j.appender.ConversionPattern=%d{HH:mm:ss,SSS}{GMT} %-4r %-5p [%t] %3x - %m%n

推荐答案

我有 log4j-1.2.16 并且以下行正常工作:

I have log4j-1.2.16 and the following lines work properly:

log4j.appender.A1.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{ISO8601}{GMT} [%-5p] [%t] [%F:%L] - %m%n

如果它不起作用,那么您必须下载附加内容(companios 部分).这个包包含增强模式布局:下载 apache-log4j-extras

If it doesn't work, then you have to download extras (companios section). This package contains EnhancedPatternLayout: Download apache-log4j-extras

这篇关于日志4J;如何使用 ConversionPattern 确保时间戳始终在 GMT 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆