EventLogQuery中的日期格式?

时间:2013-08-20 17:32:22

标签: .net c#-4.0

我想构建查询字符串以在日期范围内查询事件日志。我这样做如下。但是面对无效的查询错误,“指定的查询无效”。我将我的查询与Eventlog查看器XML视图中提供的过滤器进行了比较。

* [System [Provider [@Name ='。NET Runtime'或@ Name ='Application Error'或@ Name ='Application Hang']和TimeCreated [@ SystemTime> ='2013-08-13T17:29: 56.000Z'和@ 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())

        {
        }  

请告诉我上述代码中有什么问题?

0 个答案:

没有答案