i have a problem with my server date configuration and java running log4j and solr on ubuntu 10.04.
System time is CEST.
date command output:
# date
Di 31. Jul 14:05:02 CEST 2012
but the time in the logs of my application logging with log4j is:
2012-07-31 12:05:02
i use this line in my log4j.properties file:
log4j.appender.rollingFile.layout.ConversionPattern=%d{ISO8601} %p %t %c - %m%n
Now i build a jar to test the time containing basically two lines of code:
Date date = new Date(System.currentTimeMillis());
System.out.println(DateFormat.getDateTimeInstance().format(date));
this gives me the expected wrong output:
# java -jar javaDate.jar
31.07.2012 12:05:02
if i use the virtual machine parameter for timezone it works correctly
java -Duser.timezone=Europe/Berlin -jar javaDate.jar
31.07.2012 14:05:02
but if i use the same parameter to start the application that is using log4j is still get the wrong timestamps in my log.
why????
If you’re using a recent version of log4j you should be able to use the EnhancedPatternLayout if you add:
to your config and use
in your layout.