.Net 4.5的EventSource ETW提供程序在提供程序列表中未显示

5
我一直在运用.NET4.5的新功能ETW(EventSource)进行工作。我遇到的问题是:在perfmon->数据收集器设置中,我无法看到它出现在跟踪提供程序列表中。但我能够使用perfview查看日志。
我能够通过EventSource类的静态方法GenerateManifest生成清单,这将为EventSource类中的myevents提供清单,但不包含有关通道的详细信息。
我的问题是,如何在生成perfmon跟踪会话的清单文件后添加特定于通道的信息?我还想使用Perfmon的跟踪会话来启用提供程序,而不是perfview。
非常感谢您提供任何意见。

你解决了这个问题吗?我也遇到了同样的情况,有点迷茫! - Pedro
2个回答

9
MS发布了一个Nuget包,该包可以在构建后注册EventSource类: http://blogs.msdn.com/b/dotnet/archive/2013/08/09/announcing-the-eventsource-nuget-package-write-to-the-windows-event-log.aspx

Registering your EventSource

When you install the EventSource NuGet package, the build step previously mentioned generates the following files for each EventSource in your application:

<AssemblyName>.<EventSourceTypeName>.etwManifest.man
<AssemblyName>.<EventSourceTypeName>.etwManifest.dll.

These files need to be registered with the operating system to enable channel support. To do this you run the following command after the files are in their final deployed location:

wevtutil.exe im <EtwManifestManFile> /rf:"<EtwManifestDllFile>" /mf:"<EtwManifestDllFile>"

Once this registration command is executed, all subsequent calls to MinimalEventSource.Log.Load(), from any process on that machine, will automatically result in events in the Windows Event log.

注册成功后,您应该在读取已安装提供程序的所有工具中看到它。


注册后,您可能需要重新启动事件查看器。 - Eric MSFT
我可以在 Perfmon 中看到我的,但在事件查看器中却看不到 -> 创建自定义视图,即使多次重启事件查看器也是如此。 - HashTagDevDude

0

即使您修改清单,EventSource实现也会防止您指定通道。在将事件写入ETW时,您传递一个描述符块,在其中指定通道ID。不幸的是,EventSource没有提供通过属性或其他方式设置此项的方法,并且始终将其设置为零,这意味着不使用任何通道。

EventSource的行为与普通的ETW提供程序有些不同,因为它不通过win32资源公开其清单,而是发送一个“已知”的ETW事件,其中清单作为其有效负载。这就是为什么perfmon是唯一能够识别来自.NET 4.5 EventSource发送的事件的ETW启用工具。

*您始终可以使用perfmon或类似的工具接收事件,但它们无法解码有效负载,例如传递给WriteEvent的参数。

编辑:请参见类似问题的答案

祝好 Lars


嗨,Lars,我经过相当多的研究和阅读找到了一种方法来记录事件日志中的事件并在事件查看器中查看它们以及有效负载解码...请参见我的上面的文档... - Suneet Nangia

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接