On May 6, 2008, at 12:44 PM, Das, Amar wrote:
Hi:
I have a program running on a server in Dallas. I need to generate
log4j
output in timezone "America/New_York". How can I do that?
Current configuration is
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
Thanks
log4j usage questions should be asked on [EMAIL PROTECTED]
The enhanced pattern layout in the extras companions supports time
zone specifiers on date formats. To use:
Download the extras companion from http://logging.apache.org/log4j/companions/extras
and place jar on classpath.
log4j.appender.stdout.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{}{America/
New_York} %p [%c] - %m%n
The contents of the second brace pair is passed to
java.util.TimeZone.getTimeZone() to get the appropriate time zone.
There is a guaranteed set of time zone identifiers and then a lot that
are platform or implementation specific. If you use "America/
New_York", your configuration file may not work properly if you change
platforms or implementations. See the documentation of
java.util.TimeZone.getTimeZone() for more specifics.