Control Log4j message timezone
If your server is running in one timezone, but you want to have log messages be printed using different timezone, here is a simple solution:
- Add log4j extras to project classpath (maven GAV is log4j:apache-log4j-extras:1.0)
- In log4j.xml use EnhancedPatternLayout, specifying required timezone for logging purposes (see example below for EST TZ)
In this example, log messages will be printed using EST regardless of your server timezone.
Written on December 27, 2010