Reputation: 435
I am trying to configure my log4j to log in UTC.
I can't find a clear example how to do it. I saw the following thing (but just on one place):
%d{yyyy-MM-dd HH:mm:ss zzz}{GMT}
Does that means that after the time format if I add {UTC} I will start to receive logs in UTC or there is something more?
Upvotes: 4
Views: 7545
Reputation: 2938
log4j.appender.A1.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.A1.layout.ConversionPattern=[%d{ISO8601}{GMT}] %-4r [%t] %-5p %c %x - %m%n
Upvotes: 3
Reputation: 72636
You need to use the EnhancedPatternLayout then you can use the {GMT+0}
specifier as per documentation.
If you instead you want to run your application in UTC timezone, you can add the following JVM parameter :
-Duser.timezone=UTC
Upvotes: 3