What are the main differences between the EventSource and EventProvider classes?
I understand both classes to be an event provider for ETW. If there aren't key differences in the two then what are the pros and cons.
I use the EventSource class simply because I found more examples/documentation online, and it seemed more straightforward to implement Channel support (writing to the default channels in the Event Viewer - admin, operational, analytic, and debug) because the EventRegister class automatically creates the manifest (described here).
In .NET 3.5 the EventProvider
class was the only option for tracing using ETW. As the documentation states, you must create an Instrumentation Manifest file for your custom events, which describes the data types inside your messages. This is not such easy task, and it requires using separate tools, such as the Manifest Generator (ecmangen.exe). For more information, please see this post.
The EventSource
class was added in .NET 4.5 and it introduced a simpler approach to writing your own events using ETW. Instead of creating these manifest files, they are automatically created for you, sparing the overhead.
I don't see any reason to use EventProvider
given the above. As you mentioned, EventSource
is more documented and much easier to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With