如何找到正确的协议名称 Eventlog c#
How to find the correct protocol name Eventlog c#
我的任务:
我想显示来自我的 printjobs 的 windows 事件日志的条目。
我从 msdn 和不同的站点找到了各种教程,但我无法访问我的首选 protocol/service 名称。
Microsoft-Windows-打印服务
my Code ( c#):
string lists = EventLog.LogNameFromSourceName("Microsoft-Windows-PrintService/Operational", ".");
但是这段代码不起作用。有人知道我的问题的解决方案或解决方法吗?
这是我在 C# 中的第一个项目。
提前致谢!
您的调用语法正确。我认为您在调用中指定的来源可能不存在。
如果你调用 EventLog.SourcesExists("Microsoft-Windows-PrintService/Operational") 它 return 是假的吗?如果是这样,那么您传递的源字符串不正确,您需要从事件查看器中找到正确的源。
编辑:为了回应您后来的 post,我认为权限与它没有任何关系。我无需执行任何特殊操作即可访问 "Application and Services Logs" 个资源。
根据前面的post event log sources cannot be listed from the API but must be mined from the registry. However, I did find an application EventLogSourcesView可以生成所有事件源的列表。它可能有助于找到您正在寻找的来源。
祝你好运!
感谢您的回复。
是的,SourceExist 方法 return 错误。
嗯..我不知道如何找到正确的服务名称。
SoruceExist 方法 return 仅适用于 "Windows Protocols" 部分下列出的所有协议。 "Anwendungs- und Dienstprotokolle" 部分下的其他协议(我使用德语 windows 版本 - 可能翻译成 "Application-and Serviceprotocols"),方法 return 是错误的。
在此位置,日志将保存在
%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-PrintService%4Operational.evtx
我是否需要特殊权限才能 "enter" 这些日志(目前,Visual Studio 以管理员身份启动,仅.. 就够了吗?)
谢谢!
我的任务: 我想显示来自我的 printjobs 的 windows 事件日志的条目。 我从 msdn 和不同的站点找到了各种教程,但我无法访问我的首选 protocol/service 名称。
Microsoft-Windows-打印服务
my Code ( c#):
string lists = EventLog.LogNameFromSourceName("Microsoft-Windows-PrintService/Operational", ".");
但是这段代码不起作用。有人知道我的问题的解决方案或解决方法吗? 这是我在 C# 中的第一个项目。
提前致谢!
您的调用语法正确。我认为您在调用中指定的来源可能不存在。
如果你调用 EventLog.SourcesExists("Microsoft-Windows-PrintService/Operational") 它 return 是假的吗?如果是这样,那么您传递的源字符串不正确,您需要从事件查看器中找到正确的源。
编辑:为了回应您后来的 post,我认为权限与它没有任何关系。我无需执行任何特殊操作即可访问 "Application and Services Logs" 个资源。
根据前面的post event log sources cannot be listed from the API but must be mined from the registry. However, I did find an application EventLogSourcesView可以生成所有事件源的列表。它可能有助于找到您正在寻找的来源。
祝你好运!
感谢您的回复。
是的,SourceExist 方法 return 错误。 嗯..我不知道如何找到正确的服务名称。
SoruceExist 方法 return 仅适用于 "Windows Protocols" 部分下列出的所有协议。 "Anwendungs- und Dienstprotokolle" 部分下的其他协议(我使用德语 windows 版本 - 可能翻译成 "Application-and Serviceprotocols"),方法 return 是错误的。
在此位置,日志将保存在
%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-PrintService%4Operational.evtx
我是否需要特殊权限才能 "enter" 这些日志(目前,Visual Studio 以管理员身份启动,仅.. 就够了吗?)
谢谢!