0
我想查詢事件日誌中包含有大量具有EventIds與下面的代碼如何使用C#
List<string> eventIds = new List<string>() {
"4741", "4742", "4743", "4739", "4727", "4728", "4729", "4730", "4731", "4732", "4733", "4734", "4735", "4737", "4754", "4755",
"4756", "4757", "4758", "4720", "4722", "4723", "4724", "4725", "4726", "4738", "4740", "4765", "4766", "4767", "4780", "4781",
"4934", "5136", "5137", "5138", "5139", "5141"
};
var queryString = string.Format(@"*[System[EventRecordID > {0}]] and *[System[({1})]] ",
maxEventRecordId,
string.Join(" or ", eventIds.Select(x => string.Format("EventID={0}", x))));
var elQuery = new EventLogQuery(LogSource, PathType.LogName, queryString);
var elReader = new System.Diagnostics.Eventing.Reader.EventLogReader(elQuery);
List<EventRecord> eventList = new List<EventRecord>();
for (EventRecord eventInstance = elReader.ReadEvent();
null != eventInstance; eventInstance = elReader.ReadEvent())
{
//Access event properties here:
//eventInstance.LogName;
//eventInstance.ProviderName;
eventList.Add(eventInstance);
}
當我限制EventIds的數量從查詢字符串來查詢Windows事件日誌有一大套EventIds的我正在得到結果。但是對於這個大型查詢,我收到了一個查詢錯誤異常。是否有任何其他方法將大型事件ID集傳遞給事件查看器?請幫助