EnterpriseLibrary.Logging写入相差1小时的日志 [英] EnterpriseLibrary.Logging writes logs with 1 hour difference

查看:118
本文介绍了EnterpriseLibrary.Logging写入相差1小时的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在记录时遇到了一个奇怪的问题.我们正在使用Microsoft.Practices.EnterpriseLibrary.Logging库登录Web应用程序,问题是它写入的日志与当前系统时间相差1小时.

we encounter a weird problem with logging. We are using Microsoft.Practices.EnterpriseLibrary.Logging library for logging in our web application and the problem is that it writes the log with 1 hour difference from the current system time.

我们的记录器基于本文,并且我们永远不会在代码中设置日志条目中的时间. 每个日志条目都有一个看起来像这样的标题:

Our logger is based on this article and the time in a log entry is never set in code by us. Every log entry has a title which looks like this:

MainLogSource Information: 0 : Timestamp: 11/04/2011 10:15:32,因此此时间戳总是比系统时间早1小时(例如,该条目出现在11:15).

MainLogSource Information: 0 : Timestamp: 11/04/2011 10:15:32 so this timestamp always 1 hour earlier than system time (e.g. this entry appeared at 11:15).

问题出在哪里? 谢谢

推荐答案

默认情况下,企业库日志使用UTC时间戳,因此不受夏时制的影响.

By default Enterprise Library logs using UTC timestamp, so these are unaffected by daylight savings time.

您可以在.config文件中更改格式器以使用本地时间(请参阅附件问题),但是请注意,如果更改夏令时,这将导致重复的条目.

You can change the formatter in the .config file to use local time (see attached question), but be aware that this will result in duplicate entries when daylight savings time changes occur.

Enterprise Library 5.0-应用程序日志记录-错误的DateTime

这篇关于EnterpriseLibrary.Logging写入相差1小时的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆