SoFunction
Updated on 2025-03-08

Log4j Implementation method for configuring log printing time zone

og4j version: 2.8.1

I encountered a problem when developing desktop programs. The log time in idea and the log time in CMD are normal. After running the exe made by exe4j, the log time is 8 hours less, and the time zone becomes wrong.

I searched online and found no solution to similar problems. Later, I finally found the corresponding solution in stack overflow

In the configuration file, just configure it as follows

<!-- Output log format -->
<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:}{GMT+8} [%thread] %level [%C{1}:%L] - %msg%n"/>

It seems that the lower version of log4j is not possible, there is no verification

The above method of implementing Log4j configuration log printing time zone is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.