2

The logman tool can list all providers currently enabled for a running trace event session, e.g.:

logman query -ets SleepStudyTraceSession

How is that achieved in code using the TraceEvent library?

https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.TraceEvent/

Bent Rasmussen
  • 5,538
  • 9
  • 44
  • 63

1 Answers1

1

You can use TraceEventSession.GetActiveSessionNames();.

Here's an example:

  var sessions = TraceEventSession.GetActiveSessionNames();

            foreach (var session in sessions)
            {
                Console.WriteLine(session);
            }
R.P
  • 171
  • 1
  • 11
  • 1
    That will get the session names, not the providers enabled for a specific session. Presumably I could perhaps attach to a running session and maybe find out. Since the question is almost 4 years old at the time of writing this, I kind of forgot the exact reason. :-) – Bent Rasmussen Jan 09 '23 at 12:31