How can I use python to look at and sort event viewer by event type?
Mark Hammond
mhammond at skippinet.com.au
Thu May 15 00:21:50 EDT 2003
junk at aol.com wrote:
> How can I use python to look at and sort event viewer by event type?
> I'm very new at programing in general so forgive me for my naivety. I
> bought Python Programming for WIN32 and there is something in there for
> reading the sourcename but I need to be able to read the Event types.
> I've tried to modify the example from the book for source name but I've
> not been able to figure it out and I'm becoming increasingly frustrated.
> I'm sure there is an easy way of doing this but I'm having a hard time
> finding it.
>
> This is the script I found for the source name.
> import win32evtlog
> h=win32evtlog.OpenEventLog(XYZ, "Application")
> flags=win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ
> records=win32evtlog.ReadEventLog(h, flags,0)
> records[0].SourceName
>
> If I substitute SourceName for EventType I get a number but I want it to
> show if its a warning, success, or an error.
I think you will find the number corresponds to one of
win32evtlog.EVENTLOG_ERROR_TYPE, win32evtlog.EVENTLOG_WARNING_TYPE or
win32evtlog.EVENTLOG_INFORMATION_TYPE. There are also some other
constants for audit records etc.
Mark.
More information about the Python-list
mailing list