log4j and Timezones - help!

S

sarah.wilson

I am using log4j and would like configure my appenders with a timezone.
I want to write the same log information to two logs:
a) LOG1 has a formatted timestamp in UK time (GMT) followed by the
message
b) LOG2 has a formatted timestamp in US time followed by the message

My messages are currently coming out in UK time.

I am new to java.
Can anyone suggest the best way to do this? I think I need to extend
PatternLayout in some way but don't know where to start.

Thanks alot for your help
 
R

Rhino

I am using log4j and would like configure my appenders with a timezone.
I want to write the same log information to two logs:
a) LOG1 has a formatted timestamp in UK time (GMT) followed by the
message
b) LOG2 has a formatted timestamp in US time followed by the message

My messages are currently coming out in UK time.

I am new to java.
Can anyone suggest the best way to do this? I think I need to extend
PatternLayout in some way but don't know where to start.

Thanks alot for your help
I don't know anything about log4j but I have a design comment.

Wouldn't it be better to have a single log with all timestamps using the
same timezone - which everyone has agreed upon first, if possible - than to
have multiple logs with timestamps that use different timezones? Otherwise,
I suspect you're going to run into more confusion down the road as different
people discuss the same problems but each have different timestamps for the
same events. For instance, Nigel in the UK says to his colleague Bob in New
York: "See here Bob, old chap, I have a bit of a sticky wicket at 3:24:17 in
the log." Bob replies "I don't see nothin' wrong at 3:24:17. But I'm glad
y'all called 'cuz there's something nasty at 8:24:17 in my log.". Their
colleague Dave, who is in L.A. and is part of the conference call (and has
his own log which uses Pacific Standard Time), says "I don't know what you
dudes are talkin' about; my log shows a bad problem at 11:24:17 but those
other times are just fine." [Forgive the exaggerated dialog ;-)]

See my point? If people in different locations each get a log with the same
events but with the timestamps in their own timezone, it would tend to make
it harder to collaborate on problems. Or that would be my guess anyway,
never actually having experienced the situation I'm describing.

Rhino
 
S

sarah.wilson

fair point.
We actually have a single clock at the moment (UK time) and this is
causing confusion with the local support teams who have to adjust from
GMT mentally before dealing with a problem.
The US log is for problems which have to be dealt with wholly in the
US, we will have a Spanish log for Spanish problems etc. (no
"sticky-wicket y'all" conversations but I like the characterisation!)

Any transatlantic conversations would involve refering to the central
log as you suggest. At the moment this is not a likely scenario so I am
not planning on adding two timestamps to the US log for the moment.
I'll bear this in mind for the future in the formatter though...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top