Question

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.

Was it helpful?

Solution 2

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top