I have a web app which upon startup stores the server local timezone in a global static member and then sets the DefaultTimeZone of JVM to GMT.
During startup log4j is logging messages in server default timezone.
Now when i change my log level in log4j.properties the log level is changed dynamically and now the log4j logs messages in GMT time .
My requirement is to log messages always in server local time zone.
How can i achieve this in my scenario? any pointers will be really appreciated.
Thank you
This implies that you’ve configured log4j to watch your configuration file for changes, a configuration which is not recommended for webapps (see also this related SO question).
What is occuring is something like this
TimeZone.getDefault()returns the machine’s timezoneI’d suggest a few options here:
TimeZone getMyAppDefaultTimeZone().Changing JVM-wide defaults for something only your application code needs can have much larger unintended consequences.