I am trying to use EventSource with Microsoft.Diagnostics.EventFlow and I cannot make it output to the console. Here is an example where it works with Inputs.Trace but does not work with Inputs.EventSource:
myEventFLowConfig.json:
{
"type": "EventSource",
"sources": [
{
"providerName": "MyCompanyEventSource"
}
],
"inputs":
[
{
"type": "EventSource",
"traceLevel": "Warning"
},
{
"type": "Trace",
"traceLevel": "Warning"
}
],
"outputs": [
{
"type": "StdOutput"
}
]
}
MyEventSource.cs
[EventSource(Name = "MyCompanyEventSource")]
public class MyEventSource : EventSource
{
public static MyEventSource Log = new MyEventSource();
[Event(250, Message = "MESSAGE FROM EVENT SOURCE", Level = EventLevel.Warning)]
public void MessageFromEventSource()
{
WriteEvent(250);
}
}
console app:
public class Program
{
static void Main(string[] args)
{
using (var pipeline = DiagnosticPipelineFactory.CreatePipeline("myEventFlowConfig.json"))
{
SomeMethod();
Console.WriteLine("Press any key to exit...");
Console.ReadKey(intercept: true);
}
}
private static void SomeMethod()
{
MyEventSource.Log.MessageFromEventSource();
System.Diagnostics.Trace.TraceWarning("MESSAGE FROM TRACE");
}
}
in the console app, I am using both EventSource and Trace as inputs, however only the Trace one is shown in the console. What am I doing wrong with the EventSource that it does not show up in the console?
Thanks!