EventLogReader和EventRecord:消息在哪里? [英] EventLogReader and EventRecord: Where's the Message?

查看:219
本文介绍了EventLogReader和EventRecord:消息在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查询远程计算机上的应用程序事件日志,我求助于使用EventLogReader而不是EventLog,因为它花费很长时间才能通过EventLog找到我需要的事件.但是,即使它使用EventLogReader更快地找到了事件,我也无法弄清楚该对象上需要的信息到底在哪里...尤其是消息.

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

推荐答案

叹...这是FormatDescription()方法.我没有看到它,因为我只是在查看属性.

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

这篇关于EventLogReader和EventRecord:消息在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆