关于.net:ETW事件源名称在运行时

ETW EventSource Name at runtime

我想知道,是否可以在运行时设置事件源名称。

1
2
[EventSource(Name ="Test-SourceLogger")]
public sealed class EventSourceLogger : EventSource

我有多个应用程序想要登录到不同的EventSources。如果可以将其设置为可配置的,则可以将该组件用于EventViewer。

有关EventSourceAttribute

的其他信息

1
2
[AttributeUsage(AttributeTargets.Class)]
public sealed class EventSourceAttribute : Attribute

预先感谢。


您可以通过EventSource实例的构造函数传递事件源名称。每个新实例可以具有不同的事件源名称。只是不要使用单例模式。


我能够使用CodeDom生成此类并适当使用。感谢您的输入。