Search code examples
c#fileevent-log

How to open saved event log archive in .NET?


I have used the System.Diagnostics.EventLog to view the logs on the local computer. However, I would like to open a saved event log archive (.evt or .evtx) and view the logs that are contained in the saved file. I just need to view timestamps, messages, sources, etc. associated with the logs in the file. Can this be done in C#?


Solution

  • Check out the System.Diagnostics.Eventing.Reader namespace. Specifically the EventLogQuery class.

    http://msdn.microsoft.com/en-us/library/bb671200(v=VS.90).aspx