在某些记录中循环浏览事件日志和EventID似乎是错误的 [英] Looping through the event log and the EventID appears to be wrong on some records
问题描述
我正在遍历多个远程服务器的事件日志,并且发现".EventID"属性返回错误的整数
我的代码段:
foreach(log.Entries.Cast< EventLogEntry>().Reverse()中的EventLogEntry条目){字符串EventID = entry.EventID;//此值有时不正确}
我的应用程序提取的eventID为263169,但实际的eventID为1025
关于为什么这个.EventID属性仅在95%的时间内正确的任何想法吗?
如
My Code Snippet:
The eventID my application is pulling is 263169 but the actual eventID is 1025 Any idea as to why this .EventID property is correct only 95% of the time? As described here: Windows event viewer treat EventID as 16-bit integer (at least it's so as I test in WinXP), so you can cast it to UInt16 to display the same ID as in Event Viewer.
这篇关于在某些记录中循环浏览事件日志和EventID似乎是错误的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! foreach (EventLogEntry entry in log.Entries.Cast<EventLogEntry>().Reverse())
{
string EventID = entry.EventID; //this value is sometimes incorrect
}
foreach (EventLogEntry entry in log.Entries.Cast<EventLogEntry>().Reverse())
{
var EventID = (UInt16)entry.InstanceId;
}