G
Guest
Hey
I am trying to read the Windows Event Logc. In fact, I am able to read the
Event Log. My problem is that I am reading and filtering a large log and it
takes a very very very very long time to complete. I am using the ordinary
technique for reading/writing from and to the Event Log. I am wondering if
there is a better way to speed things up. Below is an excerpt of the code I
am using (notice that I am filtering by Category and TimeGenerated; again
this works fine on small logs but is painfully sloooooooowwwww on large ones):
DateTime eventDate = DateTime.MinValue;
EventLog eventLog = new EventLog(logName, machine);
foreach(EventLogEntry logEntry in eventLog.Entries)
{
if(logEntry.Category == "Logon/Logoff" && logEntry.TimeGenerated > eventDate)
{
//print the values
Console.Write(Convert.ToString(logEntry.EntryType) + "\t" +
logEntry.TimeGenerated.ToString() + "\t" + logEntry.Category + "\t" +
logEntry.UserName + "\n");
}
}
Please help.
Thanks
KK
I am trying to read the Windows Event Logc. In fact, I am able to read the
Event Log. My problem is that I am reading and filtering a large log and it
takes a very very very very long time to complete. I am using the ordinary
technique for reading/writing from and to the Event Log. I am wondering if
there is a better way to speed things up. Below is an excerpt of the code I
am using (notice that I am filtering by Category and TimeGenerated; again
this works fine on small logs but is painfully sloooooooowwwww on large ones):
DateTime eventDate = DateTime.MinValue;
EventLog eventLog = new EventLog(logName, machine);
foreach(EventLogEntry logEntry in eventLog.Entries)
{
if(logEntry.Category == "Logon/Logoff" && logEntry.TimeGenerated > eventDate)
{
//print the values
Console.Write(Convert.ToString(logEntry.EntryType) + "\t" +
logEntry.TimeGenerated.ToString() + "\t" + logEntry.Category + "\t" +
logEntry.UserName + "\n");
}
}
Please help.
Thanks
KK