I've been trying to work with ETW in .net 4.0.
I have started using Microsoft EventSource Library 1.0.4-beta (https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.EventSource)
Here is the code i written for generating events for my application.
[EventSource(Name = "Samples-EventSourceDemos-EventSourceLogger")]
public sealed class EventSourceLogger : EventSource
{
public static EventSourceLogger Log = new EventSourceLogger();
public static string GetManifest()
{
return GenerateManifest(typeof(EventSourceLogger), null);
}
[Event(200, Level = Microsoft.Diagnostics.Tracing.EventLevel.Informational, Task = EventTask.None, Version = 1,
Opcode = EventOpcode.Info, Keywords = EventKeywords.None, Channel = EventChannel.Admin,
Message = "Test Message")]
public void LogEtwInfoEventMessage(string jsonArgs)
{
if (!this.IsEnabled()) return;
this.WriteEvent(200, jsonArgs);
}
[Event(400, Level = Microsoft.Diagnostics.Tracing.EventLevel.Error, Task = EventTask.None, Version = 1,
Opcode = EventOpcode.Info, Keywords = EventKeywords.None, Channel = EventChannel.Admin, Message = "Test Message")]
public void LogEtwErrorEventMessage(string jsonArgs)
{
if (!this.IsEnabled()) return;
this.WriteEvent(400, jsonArgs);
}
[Event(500, Level = Microsoft.Diagnostics.Tracing.EventLevel.Warning, Task = EventTask.None, Version = 1,
Opcode = EventOpcode.Info, Keywords = EventKeywords.None, Channel = EventChannel.Admin, Message = "Test Message")]
public void LogEtwWarningEventMessage(string jsonArgs)
{
if (!this.IsEnabled()) return;
this.WriteEvent(500, jsonArgs);
}
}
I am not able to generate manifest from listener. Code Below
var manifestXml = EventSourceLogger.GetManifest();
When I try to call this I get NullReferenceException, Please suggest I am missing any thing. Is it possible to push EventMessage to EventViewer using this version.
As Part of this NuGet Package, I have eventRegister, Install Bat, Microsoft.Diagnostics.Tracing.EventSource.targets. I am not really sure how these would help in manifest generate.
If any one have any ideas (or) worked on this, Please help.
Thanks in advance.