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.

有帮助吗?

解决方案 2

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top