system event viewer help
Mark Hammond
mhammond at skippinet.com.au
Wed Jun 4 22:18:12 EDT 2003
junk at aol.com wrote:
> When I run this script instead of giving me information from my System
> log it pulls information from my Application log. I'm sure I'm missing
> something simple but I cant seem to get it to work no matter what I do.
>
>
> import win32evtlog, win32evtlogutil
> win32evtlog.OpenEventLog(None, "System")
> win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ
> print "Event Viewer System log"
> def CheckRecord(record):
> if str(record.EventType)=="2":
> print "Have Warning for %s written at %s" % \
> (record.SourceName, record.TimeWritten.Format())
> elif str(record.EventType)=="1":
> print "Have Error for %s written at %s " % \
> (record.SourceName, record.TimeWritten.Format())
> win32evtlogutil.FeedEventLogRecords(CheckRecord)
You must also pass the "log name" to FeedEventLogRecords.
Mark.
More information about the Python-list
mailing list