【问题标题】:EventLogReader and EventRecord: Where's the Message?EventLogReader 和 EventRecord:消息在哪里?
【发布时间】:2012-09-05 00:37:53
【问题描述】:

我想在远程计算机上查询应用程序事件日志,我使用EventLogReader 而不是EventLog,因为使用EventLog 查找我需要的事件需要很长时间。然而,即使它使用EventLogReader 更快地找到事件,我也无法弄清楚我需要的信息到底在哪里……尤其是消息。

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

【问题讨论】:

  • 再次使用事件查看器进行救援。是否有一个或多个 entry.EventData 属性(一个名为 Data 的枚举或只是多个命名属性)?我有点摸不着头脑,但您也可以打开 eventvwr.msc,打开一个随机事件,然后查看 XML 视图。
  • @lc。我只是想通了并发布了答案。感谢您的帮助。
  • 是的,在 MSDN 中没有这方面的文档太糟糕了。很抱歉只在黑暗中刺伤:-P
  • @lc。我很高兴有人试图提供帮助:)

标签: c# event-log


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 2013-05-12
    • 2021-01-13
    相关资源
    最近更新 更多