Link to home
Create AccountLog in
Avatar of Ken H.
Ken H.

asked on

Parse .evt files with vb.net

I'm looking for code that will parse .evt log files in vb.net. I have found examples in C# but not vb.

The .evt files are not the local system files. They are part of a data collection performed from remote hosts so i'm looking for code where I can specify a filepath to the .evt files.

Code that outputs to a gridview would be nice. I'm sure this has been done time and time again by different people so I'd rather not "recreate the wheel" and just use what's out there.



Avatar of Ken H.
Ken H.

ASKER

My code so far is simple but it's not returning the log.

Breakpoint shows "Network path not found" ... so i must be doing something wrong but based on the MS EventLogEntry class my code should be correct to pull the log "EventLog(String, String, String)". Not sure about my dropping it to a multiline text box but I've gotta get the data in before I worry about that.
Dim appLog As New EventLog("Application Event Log", txtHostName.Text, txtPath.Text & "\SystemInfo\Application_EventLog.evt")
        Dim entry As EventLogEntry
        For Each entry In appLog.Entries


            txtOut.Text &= entry.Message

        Next

Open in new window

Avatar of Nasir Razzaq
Avatar of Ken H.

ASKER

The code for that parser is in c#. I know nothing about C and my project is in VB so i'm hoping someone can help me with a vb implementation.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Ken H.

ASKER

Ok the only thing I'm having trouble with now is how can i code this to pull an event log from a string path?

 Dim objEventLog As EventLog = New EventLog(strLogName)

Open in new window


That expects  "Application" "System" etc. Putting a string value to a .evt file throws an exception.
Avatar of Ken H.

ASKER

I'm accepting this as the solution because I was not aware of these. I'm sure this will come in useful at some point.

The route I am taking with this issue is to convert the .evt files into .csv using the microsoft logparser tool. Then from the CSV file I will bring the data into my application.