Hey out there,
i'm trying to write a simple application for reading the EventLog from Windows.
For example i want to display all entrys with the Level "Critical" / Level 1 in XML
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Level>1</Level>
In .NET are only this Types available:
public enum EventLogEntryType
{
Error = 1,
Warning = 2,
Information = 4,
SuccessAudit = 8,
FailureAudit = 16,
}
So there is no Critical.
I searched in the net and found
this link.
I tryed it out but if i use it like this
EventLog log = new EventLog( "Application" );
foreach( EventLogEntry entry in log.Entries )
{
if( entry.EntryType == 0 )
Console.WriteLine( "<{0} {1} {2}>", entry.EventID, entry.Source, entry.Message );
}
it put more lines out than the EventLog Viewer from Microsoft if i limit to "Critical" errors only in my "Application" Protocol (3 Entrys here).
Even if i try the post at the link and do it like this
if( (entry.EntryType != EventLogEntryType.Error) &&
( entry.EntryType != EventLogEntryType.FailureAudit ) &&
( entry.EntryType != EventLogEntryType.Information ) &&
( entry.EntryType != EventLogEntryType.SuccessAudit ) &&
(entry.EntryType != EventLogEntryType.Warning) )
{
Console.WriteLine( "<{0} {1} {2}>", entry.EventID, entry.Source, entry.Message );
}
nothing usable here...
So is there a way i can limit only to the critical entrys using C#?
Thank you so much guys for your help!