Date format in EventLogQuery?
I want to build query string to query Event log with in a date range. I am doing it as below. But facing invalid query error, "Specified query is invalid". I compared my query with the filter provided in Eventlog viewer XML view.
*[System[Provider[@Name='.NET Runtime' or @Name='Application Error' or @Name='Application Hang'] and TimeCreated[@SystemTime>='2013-08-13T17:29:56.000Z' and @SystemTime<='2013-08-14T17:29:56.999Z']]]
string queryString = "*[System[Provider[@Name='Application Error' or @Name='Application Hang' or @Name='ThomsonONE' or @Name='DFContainer'] and TimeCreated[@SystemTime>='" + "2013-08-13T04:00:00.000Z" + "' and @SystemTime<='" + "2013-08-14T03:59:59.999Z" + "']]]";
EventLogQuery eventsQuery = new EventLogQuery(fileNames[0], PathType.FilePath, queryString);
EventLogReader logReader = new EventLogReader(eventsQuery);
for (EventRecord eventInstance = logReader.ReadEvent();
null != eventInstance; eventInstance = logReader.ReadEvent())
{
}
Please let me know whats wrong in this above code?
链接地址: http://www.djcxy.com/p/92496.html下一篇: EventLogQuery中的日期格式?