KRP
KRP

Reputation: 131

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.

Upvotes: 1

Views: 1034

Answers (1)

Zeljko
Zeljko

Reputation: 310

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.

Upvotes: 1

Related Questions