Oxygen
Oxygen

Reputation: 871

How to export Event Viewer logs to csv using C#

We are looking into writing a C# program which will export Event Viewer logs into csv file.

DateTime              |Level    | Source | EventID | Detail
06/16/2016 10:11:01    Error       ABC      100      Detail of event error

Can you please guide/hint if you knows anything which suits for this? Thank You!

Upvotes: 0

Views: 1774

Answers (1)

Maiko Kingma
Maiko Kingma

Reputation: 929

This application exists of two parts. 1. Reading the eventlog 2. Writing to a csv file

Reading the eventlog is built in to .NET. Examples can be found here. The application might need administrator rights to do this.

For writing to a csv file you can use the .net file and stringbuilder classes. In a csv file each line is a row and columns are split by a comma. This is already discussed in an other question: Writing data into CSV file

Upvotes: 1

Related Questions