ETW EventSource Name at runtime

I would like to know, if we can set EventSource Name during runtime.

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

I have multiple applications who wants to log to different EventSources. If this can be made configurable i can reuse the component for EventViewer.

Additional information on EventSourceAttribute

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

Thanks in advance.


I am able to generate this class using CodeDom and use appropriately. Thanks for your inputs.


You can pass event source name through constructor of the instance of your EventSource. Every new instance can have different event source name. Just do not use singleton pattern.

链接地址: http://www.djcxy.com/p/90862.html

上一篇: 如何为语义记录应用程序块组织EventSources?

下一篇: ETW EventSource在运行时的名称