EventLogQuery time format expected?

前端 未结 5 982
孤独总比滥情好
孤独总比滥情好 2021-01-18 10:10

I\'m trying to use the EventLogQuery class to query the eventlog. I followed the example shown on http://msdn.microsoft.com/en-us/library/bb671200%28v=vs.90%29.aspx#Y0.

5条回答
  •  北海茫月
    2021-01-18 10:33

    Here is another C# for initializing an EventLogQuery object that will load event entires for a specific date range

    var startTime = DateTime.Now.AddDays(-1);
    var endTime = DateTime.Now;
    
    var query = string.Format("*[System[TimeCreated[@SystemTime >= '{0}']]] and *[System[TimeCreated[@SystemTime <= '{1}']]]",
        startTime.ToUniversalTime().ToString("o"),
        endTime.ToUniversalTime().ToString("o"));
    
    var elq = new EventLogQuery("Applicaton", PathType.LogName, query);
    

提交回复
热议问题