How can I use python to look at and sort event viewer by event type?

junk at aol.com junk at aol.com
Wed May 14 11:50:42 EDT 2003


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.




More information about the Python-list mailing list