1

I want to read some event logs that are under "Applications and Services Logs" using win32evtlog.

I can read event logs that are part of "System", "Application", "security" and other standard logs. but when I try to read some logs for example from "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational", I will get logs of "Application".

I tried to use something like the here but I can't seem to be able to do in python.

import win32evtlog

server = 'localhost'
logtype = "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"
handle = win32evtlog.OpenEventLog(server, logtype)
flags = win32evtlog.EVENTLOG_FORWAEDS_READ | win32evtlog.EVENTLOG_SEQUENTIAL_READ
while True:
    events = win32evtlog.ReadEventLog(hand, flags,0)
    if events:
        for event in events:
           print ('Source Name:', event.SourceName)
           print ('Event ID:', event.EventID)
           print ('Time Generated:', event.TimeGenerated)

I prefer to use pywin32 but it is not a must.

Shreya
  • 35
  • 2
  • 12

1 Answers1

0

There is a typo in line

flags = win32evtlog.EVENTLOG_FORWAEDS_READ | win32evtlog.EVENTLOG_SEQUENTIAL_READ

You wrote EVENTLOG_FORWAEDS_READ instead of EVENTLOG_FORWARDS_READ

kemalbastak
  • 28
  • 1
  • 3