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??
}
}
Sigh... It's the FormatDescription()
method. I didn't see it because I was only looking at the properties.