LOG4J设置UTC
log4j.appender.stdout.layout.ConversionPattern=
%d{}{America/New_York}%p[%c]-%m%n
%d{ISO8601}{GMT-5}%p[%c]-%m%n
上面的日志模式有正确的想法,但不完全正确(你没有得到任何日志中的时间戳)。
Usethispatternforsure:使用这种模式肯定:
%d{ISO8601}{America/New_York}%p[%c]-%m%n
or或
%d{ISO8601}{GMT-5}%p[%c]-%m%n
log4j.appender.ConversionPattern=%d{HH\:mm\:ss,SSS}{GMT}%-4r%-5p[%t]%3x-%m%n
log4j.appender.A1.layout=org.apache.log4j.EnhancedPatternLayoutlog4j.appender.A1.layout.ConversionPattern=%d{ISO8601}{GMT}[%-5p][%t][%F:%L]-%m%n
2004年9月28日
Here'sthelog4j.propertiesfilecodeIhave.这里是我的log4j.properties文件代码。I'mtryingtogetthe我试图让
logfiletodisplaythetimeinUTC.日志文件中显示UTC时间。Forexample,insteadof例如,而不是
2004-09-2813:00:00.000GMT-0500,Iwanttodisplay2004-09-282004-09-2813:00:00.000GMT-0500,我想显示2004-09-28
17:00:00.00GMT-0000.17:00:00.00时间-0000。Anysuggestions?有什么建议?
#ExportAutomationLog4JconfigurationProperties.#ExportAutomationLog4J配置属性。
log4j.rootLogger=@[email protected]=_AT_LOG4J_ROOT_APPENDERS的,
log4j.appender.R=org.apache.log4j.RollingFileAppenderlog4j.appender.R=org.apache.log4j.RollingFileAppenDER
log4j.appender.R.File=../beans/groupsubgroup/log/EventLog.txtlog4j.appender.R.File=。。/豆/groupsubgroup/日志/EventLog.txt的
log4j.appender.R.MaxFileSize=900KBlog4j.appender.R.MaxFileSize=900KB
#Keep20backupfiles#保持20个备份文件。
log4j.appender.R.MaxBackupIndex=20log4j.appender.R.MaxBackupIndex=20
log4j.appender.R.layout=org.apache.log4j.PatternLayoutlog4j.appender.R.layout=org.apache.log4j.PatternLaYOUT
log4j.appender.R.layout.ConversionPattern=%-5p%d{yyyy-MM-ddlog4j.appender.R.layout.ConversionPattern=%-5P%D{YYYY-MM-DD
HH:mm:ss.SSS'GMT'Z}%c[%t]-%m%nHH:MM:ss.SSSGMT'Z}%C[%T]-%M%N
log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout=org.apache.log4j.ConsoleAppe各州
log4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=>>%-4r-%m%nlog4j.appender.stdout.layout.ConversionPattern=>>%-4R-%M%N
#SMTPappender#的SMTP的appender
log4j.appender.SMTPTest=org.apache.log4j.net.SMTPAppenderlog4j.appender.SMTPTest=org.apache.log4j.net.SMTPAppender
log4j.appender.SMTPTest.layout=org.apache.log4j.PatternLayoutlog4j.appender.SMTPTest.layout=org.apache.log4j.PatternLayout
log4j.appender.SMTPTest.layout.ConversionPattern=%d%-5p[%t]-%m%nlog4j.appender.SMTPTest.layout.ConversionPattern=%%D-5P[%T]-%M%N
log4j.appender.SMTPTest.To=@[email protected]=@TO_MAIL@
log4j.appender.SMTPTest.SMTPHost=smtpna1.ford.comlog4j.appender.SMTPTest.SMTPHost=smtpna1.ford.com
log4j.appender.SMTPTest.Subject=@[email protected]=@SMTP_MAIL_SUBJECT_AT_
log4j.appender.SMTPTest.From=log4j.appender.SMTPTest.From=
log4j.appender.SMTPTest.BufferSize=50log4j.appender.SMTPTest.BufferSize=50