2

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

Ciaran Gallagher
  • 3,895
  • 9
  • 53
  • 97

1 Answers1

1

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.

George Duckett
  • 31,770
  • 9
  • 95
  • 162
  • Brilliant thanks! I was also able to find the other EventLog methods [here](http://msdn.microsoft.com/en-us/library/0acz16ca.aspx), which provide plenty of other helpful functions such as the ability to clear the event log (which I could do before running tests). – Ciaran Gallagher Jun 14 '11 at 14:53