[英]When querying the Win32_NTLogEvent Class from WMI with WQL is the TimeGenerated property based on Local time of the computer or GMT?
I am writing a C# windows service that is doing some churning through the eventlog on a few domain controllers. 我正在编写一个C#Windows服务,该服务正在通过一些域控制器上的eventlog进行一些改动。 Some of them are Windows Server 2003 and some are Windows Server 2008. Upon the service stopping I am attempting to resume where I left off in the logs.
其中有些是Windows Server 2003,有些是Windows Server2008。服务停止后,我尝试恢复在日志中停下来的位置。 In order to do this instead of
为了做到这一点,而不是
SELECT * FROM Win32_NTLogEvent WHERE --criteria for events I am looking for
I am doing 我在做
SELECT * FROM Win32_NTLogEvent WHERE TimeGenerated = --some date AND --criteria for events I am looking for
At one point I was convinced that the TimeGenerated field was in the local time of the server but now it seems that the Windows 2008 Servers are using GMT to record that time. 有一次我确信TimeGenerated字段位于服务器的本地时间,但是现在看来Windows 2008 Server使用GMT来记录该时间。 Can anyone shed some light on if this is a real different between the way the two operating systems function or is this a configuration problem?
如果这是两个操作系统的运行方式之间确实存在真正的区别还是这是配置问题,那么谁能提供一些启发?
In addition, it seems that in versions prior to Windows Server 2008 TimeGenerated was returned in local time, but changed to GMT in Server 2008, as others have been noticing. 此外,似乎在Windows Server 2008之前的版本中,TimeGenerated是在本地时间返回的,但正如其他人所注意到的,在Server 2008中已更改为GMT。
Windows time stamps are always recorded in UTC. Windows时间戳始终以UTC记录。 They will only be converted to local time in whatever GUI program you use to look at the data, like Event Viewer or Explorer (for file times).
它们只会在您用来查看数据的任何GUI程序中转换为本地时间,例如Event Viewer或Explorer(用于文件时间)。 This behavior is important to avoid random failure on daylight saving time transitions.
此行为对于避免夏令时过渡时发生随机故障很重要。
Something like this may be helpful: 这样的事情可能会有所帮助:
("Select * from Win32_NTLogEvent Where Logfile = 'Application' AND EventCode = '999' AND Message Like '%message%' AND TimeGenerated = '201202210000000000.000000+***'")
The TimeGenerated
syntax is setup backwards so in the above example its yearmonthdaytimeminutesseconds.000000+\\***
the preceding 000000+\\***
is needed. TimeGenerated
语法是向后设置的,因此在上面的示例中,需要它的yearmonthdaytimeminutesseconds.000000+\\***
之前的000000+\\***
。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.