reading an event log
i am trying to read from the event logs on the server.. my current code is working..
but my worry is when there are thousands of entries in the events, will it take longer to load the page??
here is my working code
ArrayList chromeEntries = new ArrayList();
EventLog eventLog = new EventLog("Application", ".");
foreach (EventLogEntry logEntry in eventLog.Entries)
{
if (logEntry.Source.Equals("Application Error"))
{
chromeEntries.Add(logEntry.TimeWritten);
}
}
GridView1.DataSource = chromeEntries;
GridView1.DataBind();
i want to display the time entries in the application logs which have a source name of "Application Error".. my only concern is for each...?? is my concern开发者_开发问答 valid ? or the above code is just fine..
any suggestions
thanks
ok i tried this
EventLog eventLog = new EventLog("Application", ".", "Application Error");
Label1.Text = eventLog.Entries.Count.ToString();
but it counts the entire entries instead of just counting entries for Application Error
It will absolutely take substantially longer to load the page if there are thousands of entries. You might want to consider using WMI to query the log instead of just iterating through everything.
精彩评论