문제

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