简体   繁体   English

log4j XMLLayout中的时间戳错误

[英]Wrong timestamp in log4j XMLLayout

I set my log4j configuration to use two appenders (ConsoleAppender and RollingFileAppender) the ConsoleAppender is using this layout (PatternLayout: ConversionPattern=%d [%t] %-5p %c - %m%n) and the RollingFileAppender is using XMLLayout. 我将log4j配置设置为使用两个附加程序(ConsoleAppender和RollingFileAppender),ConsoleAppender使用此布局(PatternLayout:ConversionPattern =%d [%t]%-5p%c-%m%n),而RollingFileAppender使用XMLLayout。 So the problem is that the ConsoleAppender output is displaying the correct date when I log an error, let's say "05/28/2010 12:45 PM" but the XMLLayout timestamp attribute is being set 5 hours into the future, when I convert that epoch value to DateTime I got "05/28/2010 5:45 PM". 因此,问题在于,当我记录错误时,ConsoleAppender输出显示正确的日期,比如说“ 05/28/2010 12:45 PM”,但是将XMLLayout timestamp属性设置为将来的5小时(当我将其转换时)到DateTime的纪元值,我得到“ 2010年5月28日下午5:45”。 I even used http://www.epochconverter.com/ to check if my conversion algorithm was wrong and the result was the same. 我什至使用http://www.epochconverter.com/来检查我的转换算法是否错误以及结果是否相同。 Any idea why is this happening? 知道为什么会这样吗?

Thanks 谢谢

Sounds like one conversion is respecting UTC offset and one (the one in the future) is not. 听起来好像一种转换在考虑UTC偏移,而另一种(在将来)。 You're in the EDT timezone, correct? 您在EDT时区,对吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM