How can i read the windows event log by particular Source, Date time and category??
Asked
Active
Viewed 2,924 times
3 Answers
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.
Lukas Šalkauskas
- 14,191
- 20
- 61
- 77
0
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!
Rob
- 3,488
- 3
- 32
- 27
0
You could use additional software called "Log Parser"
Comes with an API you can use, check the help file once installed :)
Piotr Kula
- 9,597
- 8
- 59
- 85
S Philp
- 452
- 3
- 14
-
A sample code using log parser would make your answer extremly helpful. Even though I'd rather use internal System.Diagnostics to read the log - Somebody else might find this useful. If you update i will +1 – Piotr Kula Oct 24 '12 at 12:10