Log4J;如何使用ConversionPattern确保时间戳总是在格林威治标准时间?[英] Log4J; how to ensure timestamps are always in GMT using ConversionPattern?

本文是小编为大家收集整理的关于Log4J;如何使用ConversionPattern确保时间戳总是在格林威治标准时间?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

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

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

推荐答案

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

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

如果它不起作用,则必须下载Extras(Comparios Section). 此软件包包含EnhancedPatternlayout: 下载apache-log4j-extras

本文地址:https://www.itbaoku.cn/post/1574807.html

问题描述

How can I ensure that all timestamps that my log4j is using, are in 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

推荐答案

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

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