I'd like to be able to declare an EventSource which has a minimum of several methods which by default provide regular logging facilities.
e.g.
In addition I'd like to be able to within each service, define a specific event source that inherits from the base class providing the above. At the moment the EventRegister.exe app which creates the manifest complains that the event source must be sealed.
Am I doing this wrong? If so how can I achieve the above? See example code:
public class ETWBase : EventSource
{
[Event(1, Channel = EventChannel.Admin, Message = "Info Message: {0}")]
public void Info(string message) { this.WriteEvent(1); }
[Event(2, Channel = EventChannel.Debug, Message = "Debug Message: {0}")]
public void Trace(string message) { this.WriteEvent(2); }
}
[EventSource(Name = "ABC-MyEtwServiceEventSource")]
public sealed class MyEtwServiceEventSource : ETWBase
{
public static MyEtwServiceEventSource Log = new MyEtwServiceEventSource();
[Event(3, Channel = EventChannel.Debug, Message = "My specific Message: {0}")]
public void Trace(string message) { this.WriteEvent(3); }
}
I'm using the latest and greatest Microsoft.Diagnostics.Tracing (pre) which I understand has support for Channels unlike the SLAB from Enterprise Library.
ETWBase should be abstract and should not have methods decorated by EventAttribute.
You could find more information in documentation file _EventSourceUsersGuide.docx
that is being added to your project if you are referencing Event Source or Event Source Samples nuget packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With