How can i read the windows event log by particular Source, Date time and category??
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Consider using EventLog Class.
EventLog lets you access or customize Windows event logs, which record information about important software or hardware events. Using EventLog, you can read from existing logs, write entries to logs, create or delete event sources, delete logs, and respond to log entries. You can also create new logs when creating an event source.
回答2:
You could use additional software called "Log Parser"
Comes with an API you can use, check the help file once installed :)
回答3:
I know this question is mighty old, but I spent a good deal of time today building a solution to this so I thought I would share:
Dim myEventLogEntryCollection As EventLogEntryCollection = New EventLog("Application", System.Environment.MachineName).Entries
Dim myEventLogEntryArray(myEventLogEntryCollection.Count - 1) As EventLogEntry
myEventLogEntryCollection.CopyTo(myEventLogEntryArray, 0)
Dim QueryLog As System.Linq.IQueryable(Of EventLogEntry) = myEventLogEntryArray.AsQueryable
QueryLog = QueryLog.Where(Function(i As EventLogEntry) i.Source = "MyParticularSourceName")
For Each Entry As EventLogEntry In QueryLog
'... your code goes here
Next
myEventLogEntryCollection = Nothing
myEventLogEntryArray = Nothing
Hope it helps others!