Log4J; How to guarantee that timestamps are always in GMT using ConversionPattern?

How can I guarantee that all timestamps that my log4j uses are in GMT?

I 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 
+9
timestamp gmt log4j
source share
1 answer

I have log4j-1.2.16 and the following lines work as expected:

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

If this does not work, then you need to download add-ons (companios section). This package contains EnhancedPatternLayout: download apache-log4j-extras

+11
source share

All Articles