EventLogReader and EventRecord: Where's the Message?

青春壹個敷衍的年華 提交于 2020-01-12 14:01:28

问题


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??
        }
    }

回答1:


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



来源:https://stackoverflow.com/questions/12380601/eventlogreader-and-eventrecord-wheres-the-message

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!