Search code examples
c#event-log

How to convert .evtx eventlog to csv


My windows service needs to save the contents of one eventlog to a file. This is done by EventLogSession.ClearLog. However, i cannot force it to save the eventlog to CSV directly. The saved format is EVTX.

            EventLogSession els = new EventLogSession();

            //stel de filename samen door het appdata pad te combinen met een tempfile name
            string tempData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "templog.csv");
            // Clears all the events and archives them to the .evtx file

            els.ClearLog(eventLogName, tempData); //  Backup File Path

How can i force the EventlogSession class to save directly to CSV, or, if that is impossible. How do i convert an EVTX to CSV (using C# or VB.net)

Thanks!


Solution

  • It turned out that all existing solutions didn't meet my requirements. I simply wanted a tool that takes an evtx as input and exportes a csv. Nothing more nothing less. I built one myself and it workes fine. Its called EVTX2CSV

    You can download it here: http://essaver.net/evtxecsv or directly via http://www.essaver.net/downloads/setupevtx2csv.exe