1
下面是代碼,它給出了總共87399個日誌號,但是在讀取日誌時它只返回一個7個記錄列表。使用win32evtlog模塊讀窗口事件日誌
import win32evtlog
server = 'localhost'
logtype = 'Application'
hand = win32evtlog.OpenEventLog(server,logtype)
flags = win32evtlog.EVENTLOG_SEQUENTIAL_READ | win32evtlog.EVENTLOG_BACKWARDS_READ
total = win32evtlog.GetNumberOfEventLogRecords(hand)
events=win32evtlog.ReadEventLog(hand,flags,0)
print "Total number of Event record ",total #Returning 87399
print "Log record read",len(events) #Returning 7
for event in events:
print 'Event Category:', event.EventCategory
print 'Time Generated:', event.TimeGenerated
print 'Source Name:', event.SourceName
print 'Event ID:', event.EventID
print 'Event Type:', event.EventType
print 'Computer Name:', event.ComputerName
print 'Data Name:', event.Data
print type(event)
如何讀取所有日誌記錄?
在此先感謝
謝謝,夥計。它真的幫助了我。 –