Apache Log4j Logging with specific timezone

后端 未结 6 1955
半阙折子戏
半阙折子戏 2021-02-19 07:32

I want the log should contain date entries of specific timezone. Is there any way of forcing timezone in log4j.properties?

Now I am using JDK 1.5, As you al

6条回答
  •  臣服心动
    2021-02-19 08:09

    This will allow you to see timezone information in each line of your logs:

    %d{yyyy-MM-dd/HH:mm:ss.SSS/zzz}
    

    The trick is to include 'zzz' in the pattern since according to Javadoc for java.text.SimpleDateFormat ( http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html ), that's the code for timezone. Log4J uses the same rules as SimpleDateFormat.

    There are more details over the in the Log4J Javadoc:

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

    Look for the row in the table where the 'Conversion Character' is the letter 'd'.

提交回复
热议问题