获取EventLog的来源 [英] Get an EventLog's sources

查看:337
本文介绍了获取EventLog的来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,专家,

我正在使用System.Diagnostics.EventLog在应用程序及其设置中记录一些事件.

对于应用程序,我认为硬编码的事件协议和源名称都可以.

由于Windows XP的集成事件查看器仅在用户告诉他之后才显示新事件,因此我也编写了一个事件查看器,使事件在创建时就显示出来.

现在,我想让这个查看器有些概括.因此,硬编码的事件协议和源名称不再是一个选项.用户可以输入协议和源名称,从而存在输入不存在的协议和源名称的风险.因此,我希望用户从仅包含有效名称的下拉列表中选择协议和来源.

有可能通过EventLog.GetEventLogs()获得所有可用的协议,但我找不到源的协议.


Hi experts,

I''m using System.Diagnostics.EventLog to log some events in an application and its setup.

For an application, I think hard-coded event protocol and source names are OK.

Since windows xp''s integrated event viewer shows new events only after the user told him, I wrote an event viewer as well, which makes events show up on creation.

Now I''d like to have this viewer a little generalized. Therefore hard-coded event protocol and source names ar no longer an option. Users could type in protocol and source names, introducing the risk of typing non-existent protocol and source names. Therefore I would like the user to choose protocol and source each from a dropdown containing valid names only.

There is a possibility to get all available protocols through EventLog.GetEventLogs() but I couldn''t find one for sources.


Is there a method to get all active sources (for a protocol or in general)?

推荐答案

这里的logs(0)是应用程序日志.您可以先检查您的条目.
Here logs(0) is Appliacation logs. You can check your entries first.
Dim logs() As EventLog = EventLog.GetEventLogs()
Dim logsE As EventLogEntryCollection = logs(0).Entries()
ComboBox1.DataSource = (From log As EventLogEntry In logsE Order By log.Source Select log.Source).Distinct.ToArray


这篇关于获取EventLog的来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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