Search code examples
c#.netwindows-server-2008windows-server-2003event-viewer

Is it possible to automate saving event viewer errors as text files?


I currently spend a considerable amount of time copying and pasting event viewer logs into text files and then copying them to a repository on another computer.

Is it possible to automate the saving these event viewer logs between a specified date/time to the computer (so that they can then be copied to the repository).

Ideally, if it's possible, it has to be achieved by C# .NET code.

The purpose of this is for automated tests, which run on Windows Server 2003/2008 machines.

Thank you


Solution

  • EventLog.GetEventLogs will get you the logs, you can then loop throught them and write to a text file. The example here will get you started.