我希望在整个Windows事件日志(例如应用程序)中查询由特定源(例如MSSQL$SQLEXPRESS)编写的事件。我已经编写了搜索事件id的工作代码:
string xpathQuery = string.Format("*[System/EventID={0}]", intFilter);
EventLogQuery query = new EventLogQuery(eventLogName, PathType.LogName, xpathQuery);
EventLogReader reader = new EventLogReader(query);
for (EventRecord eventInstance = reader.ReadEvent(); null != eventInstance; eventInstance = reader.ReadEvent())
{
lisRecords.Add(eventInstance);
}我如何改变xpathQuery,使我能够搜索4个事件日志条目源?
发布于 2014-01-17 06:52:25
更改类似的查询字符串(您可能希望创建一个文本资源,并将此查询放入其中以避免转义):
*[System[Provider[@Name='Microsoft-Windows-ADSI' or @Name='Outlook'] and (EventID=1 or EventID=2 or EventID=3)]]上述内容相当于:
(EventID in (1,2,3)) and (Source in ('Microsoft-Windows-ADSI', 'Outlook'))https://stackoverflow.com/questions/20744029
复制相似问题