logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David BalaĹžic <xerc...@gmail.com>
Subject Possible to get unambiguous timestamp with v1.2.15 ?
Date Thu, 04 Feb 2010 16:56:10 GMT

I am using log4j 1.2.15 and noticed that the timestamps in logs have
no TZ information.
They are created by config like this:

log4j.appender.A1.layout.ConversionPattern=%d DATABASE->%-5p [%c] - %m%n

Is there a way to get either:
 - same format, but with TZ info (offset), or
 - same format, but time in UTC
without switching to other or additional software?

I think I can get the first by using a pattern like %d{yyyy-MM-dd
HH:mm:ss,SSS Z}
that is using the "Z" pattern letter. That would then use
java.text.SimpleDateFormat to
do the formatting, right?
The javadocs are a bit vague:

"The date format specifier admits the same syntax as the time pattern
string of the SimpleDateFormat."

(source: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html)

It says the same syntax is used, but it is unclear it actually
SimpleDateFormat is used or a different, compatible implementation.

If it is SimpleDateFormat used, how bad is the performance hit that is
mentioned there?

For the second option, I could set the system time zone to UTC, or
maybe the applications* zone?

Any comments? Better ideas?

* - it is actually an application server, tomcat, JBoss or similar,
not set in stone yet

I also see in the API doc, that ISO8601DateFormat has a constructor
that takes a TimeZone argument.
Can that be used? Ideally just by changing the config file?


To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message