我正在使用具有以下配置的Log4j2:
# Logs Appender
rootLogger.level = INFO
rootLogger.appenderRef.file.ref = fileLogger
appender.file.type = RollingFile
appender.file.name = fileLogger
appender.file.fileName = filename.log
appender.file.filePattern = filename_%d{yyyyMMdd}.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
# Rotate log file each day
appender.file.policies.type = Policies
appender.file.policies.time.type = TimeBasedTriggeringPolicy
appender.file.policies.time.interval = 1
appender.file.policies.time.modulate = true
# Delete files older than 30 days
appender.file.strategy.type = DefaultRolloverStrategy
appender.file.strategy.delete.type = Delete
appender.file.strategy.delete.basePath = ${logsPath}
appender.file.strategy.delete.maxDepth = 1
appender.file.strategy.delete.ifLastModified.type = IfLastModified
appender.file.strategy.delete.ifLastModified.age = 30d
日志时间和系统时间相差一小时。
对于系统时间
$ date
Tue Oct 23 11:35:31 WEST 2018
产生记录时间
2018-10-23 10:35:31,922 [qtp380231503-47] INFO
此问题仅在一台服务器上发生。信息:
$ uname -a
Linux alfriptvappstest01 2.6.32-431.17.1.el6.x86_64 #1 SMP Fri Apr 11 17:27:00 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
在其他服务器和我的开发机上,它正确显示了时间。
我想念什么?
答案 0 :(得分:0)
配置您的追加程序的布局,以显示时区或强制使用特定时区。例如:
%d {ISO8601}而不是%d
更多信息,请访问: https://logging.apache.org/log4j/2.x/manual/layouts.html