简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM