views:

126

answers:

1

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

+4  A: 

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.

Steve Danner
i am looking for something in C#... i am looking but if u have any good example please let me know.. thanks..
You could just take the code in the above referenced link and pass it through a vb.net->C# converter like this one. http://www.carlosag.net/Tools/CodeTranslator/
Steve Danner