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

查看:267
本文介绍了Log4J;如何使用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"部分). 该软件包包含EnhancedPatternLayout: 下载apache-log4j-extras

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

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

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