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.
Here's a C# example for initializing an EventLogQuery object that will only load event entries from the last day.
var yesterday = DateTime.UtcNow.AddDays(-1);
var yesterdayDtFormatStr = yesterday.ToString(
"yyyy-MM-ddTHH:mm:ss.fffffff00K",
CultureInfo.InvariantCulture
);
var query = string.Format(
"*[System/TimeCreated/@SystemTime >='{0}']",
yesterdayDtFormatStr
);
var elq = new EventLogQuery("Application", PathType.LogName, query);