Apache Log4j Logging with specific timezone

后端 未结 6 1969
半阙折子戏
半阙折子戏 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 07:58

    The best way is to use the Apache Extras™ for Apache log4j™ And replace The normal PatternLayout by org.apache.log4j.EnhancedPatternLayout doing the following if using a property file:

    //log4j.appender.xxx.layout = org.apache.log4j.PatternLayout
    //Replaced by
    log4j.appender.xxx.layout = org.apache.log4j.EnhancedPatternLayout
    

    Then you can use %d{ISO8601}{GMT} instead of %d in the ConversionPattern to display your date in the GMT format. Any timezone can be specified instead of GMT

提交回复
热议问题