Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EventLogReader and EventRecord: Where's the Message?

Tags:

c#

event-log

I want to query the Application Event Log on a remote machine and I resorted to using the EventLogReader rather than the EventLog because it takes way to long to find the events I need with the EventLog. However, even though it finds the events much faster with the EventLogReader, I can't figure out where the heck the info I need is on this object... especially the message.

    public static void Load()
    {
        string query = "*[System/Provider/@Name=\"SQLSERVERAGENT\"]";

        EventLogQuery elq = new EventLogQuery("Application", PathType.LogName, query);
        elq.Session = new EventLogSession("x.x.x.x");
        EventLogReader elr = new EventLogReader(elq);

        _logEntries = new List<SqlEventEntry>();

        EventRecord entry;
        while ((entry = elr.ReadEvent()) != null)
        {
            var Message = entry.???
            // I want process the message in the event here,
            // but I can't find a property anywhere that contains the message??
        }
    }
like image 746
Brandon Moore Avatar asked Sep 12 '12 02:09

Brandon Moore


1 Answers

Sigh... It's the FormatDescription() method. I didn't see it because I was only looking at the properties.

like image 95
Brandon Moore Avatar answered Nov 09 '22 15:11

Brandon Moore