Reputation: 11
I'm using .Net feature to read events from windows event log from remote machine, like this:
var eventLogs = EventLog.GetEventLogs(Hostname);
var collection = eventLogs[0].Entries;
foreach (var item in collection)
{
//Do something
}
But this generates a lot of new SuccessAudit events in event log. Does anybody know how to prevent this new events appear in event log?
Thanks in advance
Upvotes: 1
Views: 270
Reputation: 963
Here's the deal with logs: they aim to be verbose. This 'problem' is an unfortunate side-effect of dealing with logs, but it is there by design! Imagine if anything that happens in the system could be ignored by the log. Wouldn't virus and malware makers love that (this sentence sounds so crummy, like saying the Terrorists Win)? Try not to call GetEventLogs
in too tight of a loop, and you should be OK. You can also say something like
var myLogs =
from item in collection
skip SuccessAudit logs
select logs I care about;
Upvotes: 0
Reputation: 18843
could you do this and from within the loop try to figure out what events you want to check
foreach (System.Diagnostics.EventLogEntry entry in EventLog1.Entries)
{
Console.WriteLine(entry.Message);
}
Upvotes: 0
Reputation: 2911
On my particular system I am not sure that I can avoid this. That said, I can easily avoid reading that particular event log if that is the problem. I can choose to write or read from a particular log and just avoid the 'Security' log.
Upvotes: 1