Search code examples
c#traceetw

Real-time display of events from EventProviderTraceListener in traceview


I am looking for a way to see the events logged using EventProviderTraceListener in real time. I am able to use logman to start & stop the tracing session and then decode the resulting .etl file, but I would like to see the events as they arrive.

Here is the sample C# class that I am using for testing:

public class TraceTest
{
    private static Guid ProviderGuid = new Guid("{2EC22694-F8D3-4066-B089-300DF0749C71}");
    private static EventProviderTraceListener listener = new EventProviderTraceListener(ProviderGuid.ToString(), Test Listener", "::");
    private static TraceSource source = new TraceSource("TestSource", SourceLevels.All);

    public TraceTest()
    {
        source.Listeners.Add(listener);

        source.TraceInformation("Tracing prototype.");
    }
}

Using traceview, I am able to start new tracing session by inputing the guid, but I don't know where to look for tmf files in order to be able to decode the messages - I see them arriving, but they are logged with "No Format Information found".


Solution

  • Since you do not directly log to ETW you can write your own TraceListener and add it like you add the EventProviderTraceListener (see here) or use your app.config (see here). Or you can do it using ETW, like logman and traceview, with ETWTraceEventSource like here, but that requires administrator rights to start the trace.