Enterprise Library Logging App Block的时区问题
LAB记录的日志里timestamp总是UTC时间,很是郁闷,只能把里面的DateTime.UtcNow改成DateTime.Now,再编译引用。
今天偶然看见http://blogs.msdn.com/tomholl/archive/2006/01/22/516055.aspx讲到可以修改TimeStampToken 的FormatToken方法:
然后,
Timestamp: {timestamp}
Timestamp local: {timestamp(local)}
Timestamp F: {timestamp(F)}
Timestamp local:F {timestamp(local:F)}
结果:
Timestamp: 1/23/2006 2:24:18 AM
Timestamp local: 1/22/2006 6:24:18 PM
Timestamp F: Monday, January 23, 2006 2:24:18 AM
Timestamp local:F Sunday, January 22, 2006 6:24:18 PM
马上去源码里看看,晕,原来源码里早就是这段了,那为嘛没人告诉我可以这样用呢?连配置工具里也没这标签啊!
PS:这次看的源码版本是Enterprise Library 3.1 - May 2007,不知道后来版本配置工具里有没有。