I need the to write a log message and capture that in PerfView. I would like to avoid using EventLog
or EventSource
because they are quite invasive: they require registering a new source or ETW provider, which leaves leftovers in the system.
Ideally I just want to call Debug.WriteLine
(which uses OutputDebugString), but it seems that PerfView cannot collect it. Or is there some ETW provider that sees debug messages?
If you have an answer, please state the two parts of the solution:
- What should I write in C#, and
- How to configure PerfView to capture it (if there is some ETW provider, just name it).
What you want is to use EventSource. Here you don't need to deal with GUIDs and registration to system.
Lof the data with
MinimalEventSource.Log.Information("my debug info");
and capture them with perfview withPerfView /OnlyProviders=*MinimalEventSource
. The imprtant thing is the*
. Eventsource logs the Manifest with the definitions via ManifestEvent which gets added to the ETL, so no manifest registration is required.