System.Diagnostics.Tracing.EventSource vs System.Diagnostics.Trace

user884248

I'm not sure I understand the major differences between ETW using System.Diagnostics.Tracing, and using System.Diagnostics.Trace. I understand that with both of them I can dump events onto some output stream, and that I can use various listeners to intercept this data - including custom listeners.

But except the fact that ETW's infrastructure is embdded into Windows and I can use WPR and PerfView out of the box, I don't see a difference.

When would I choose one over the other?

Kevin Gosse

System.Diagnostics.Tracing is much more complete than Trace:

  • Events are segregated by event source, meaning that you don't have to subscribe to all events (good for performance)
  • Inside of a source, events are segregated by name and "EventLevel", meaning that you can filter some more
  • Events are structured (they're not just a string, they can also have payloads to give more information)

On the other hand, System.Diagnostic.Trace is a straightforward logger: you can only log strings, and you cannot apply any kind of filtering (it is either enabled for all messages, or disabled for all). But it has the advantage of being supported per default by the Visual Studio debugger (so when you attach to the process, you directly see trace events in the output window).

I'd add that having an ETW listener provided out of the box is a nice perk of System.Diagnostics.Tracing, but technically nothing would prevent you from writing your own ETW listener for Trace.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Mono could not load type 'System.Diagnostics.Tracing.EventSource'

Can't register listeners to System.Diagnostics.Tracing.EventSource

How does System.Diagnostics.Tracing.EventSource.IsEnabled work?

System.Diagnostics.Trace vs. ILogger

System.Diagnostics.Tracing in Mono

Razor not compiling System.Diagnostics.Tracing.EventLevel

System.Diagnostics.Trace class in notepad++

What's the difference between System.Diagnostics.Trace, System.Diagnostics.Debug and System.Console?

System.Diagnostics.Trace or System.Diagnostics.WriteLine and CRM 2011 Plugin

System.Diagnostics.Trace - correct way to log exceptions

Application Insights - System.Diagnostics.Trace.* - What are these used for?

Does System.Diagnostics.Trace have any performance degredation?

Why would I turn System.Diagnostics trace autoflush off?

Could not load file or assembly 'Microsoft.Diagnostics.Tracing.EventSource

Microsoft.Diagnostics.Tracing.EventSource with the RabbitMQ.Client.dll exception

How is Visual Studio or Rider reading messages written using System.Diagnostics.Trace.Write?

Performance: System.Diagnostics.Process vs System.Management.Automation.PowerShell

how to fix this error "Microsoft.Extensions.Azure: Could not load file or assembly 'System.Diagnostics.Tracing, Version=5.0.0.0,"

Wcf - Get Request and Response with System.Diagnostics

System.Diagnostics.ActivitySource.StartActivity returns null

'Enable system diagnostics' missing in release pipeline

Is there a way to use System.Diagnostics.Process in an IAsyncEnumerator?

Output System.Diagnostics.Debug to Console

WCF System Diagnostics generates additional logs with GUID

How to create a System.Diagnostics.Process array

Use of System.Diagnostics.PresentationTraceSources.SetTraceLevel() method

PowerShell: what is System.IO.StreamWriter and System.Diagnostics.ProcessStartInfo?

Microsoft.Diagnostics.EventFlow with Inputs.EventSource

How to pass credentials/parameters to exe in System.Diagnostics.Process.Start