Reputation: 1510
In my org.ops4j.pax.logging.cfg
file, I've set:
log4j.appender.mylogger.layout=org.apache.log4j.PatternLayout
log4j.appender.mylogger.layout.ConversionPattern=%d{yyyy-MM-dd hh:mm:ss z} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
And outputs PHT (Philippine Time) my system's timezone. I'd like it to output UTC. Any help would be appreciated.
Upvotes: 1
Views: 833
Reputation: 39
I'm using log4j-1.2.17 and we forward our logs to Splunk. What I had to do was:
layout class="org.apache.log4j.EnhancedPatternLayout" param name="ConversionPattern" value="%d{ISO8601}{UTC}Z %-5p %t:%C{1}:%L [%M] %m%n"
The enhanced pattern layout allows for the timezone, and I had to add the 'Z' after for Splunk to recognize it as UTC.
Upvotes: 1
Reputation: 5285
The Extras Log4j won't work out of the box for pax-logging. You need to add those appenders to the pax-loggin-service bundle by attaching a fragment bundle to it. With that extra fragment you are able to add this extra appender to pax-logging. A example on how to attach fragments to pax-logging with karaf can be found here
Upvotes: 1
Reputation: 3202
Download the extras companion from http://logging.apache.org/log4j/companions/extras and add it to your classpath.
Following is a untested example from http://comments.gmane.org/gmane.comp.apache.logging/1143
log4j.appender.stdout.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{}{America/New_York} %p [%c] - %m%n
Upvotes: 2