Hysen Labs
Open-source project
jonwagner/EventSourceProxy avatar
jonwagner

EventSourceProxy

EventSourceProxy (ESP) is the easiest way to add scalable Event Tracing for Windows (ETW) logging to your .NET program

100 stars19 forksC#NOASSERTION
01
DEEP OPEN-SOURCE ANALYSIS

EventSourceProxy: ETW logging without the boilerplate

EventSourceProxy adds Event Tracing for Windows logging to a .NET program by generating the EventSource plumbing for you. You keep writing interfaces, it keeps writing the logging.

02
DEEP OPEN-SOURCE ANALYSIS

The pitch is about effort

The README's argument is short: you should be logging more, ETW is the best way to log on Windows, and this library makes it nearly free to add. It works against the System.Diagnostics.Tracing EventSource library and installs through NuGet. Generated IL keeps the overhead low, and close to nothing when tracing is switched off.

03
DEEP OPEN-SOURCE ANALYSIS

An interface becomes a logging source

Declare an interface, get a proxy, and calls are logged automatically once the ETW source is enabled. A calculator interface with Add and Multiply methods becomes a few lines with CreateWithActivityScope. The same mechanism works for classes that already derive from EventSource, and EventSource and Event attributes steer the generated events. Keywords, opcodes, and task enums can be reused across multiple logging sources.

04
DEEP OPEN-SOURCE ANALYSIS

Reshaping what gets logged

Version 2.0 introduced logging transforms, which use attributes and configuration rules to turn an interface call into an entirely different logging call. The email example shows fields renamed for the log, a sender traced as Sender, a recipient as Recipient, a subject and body grouped into a message, while the when argument gets ignored and a current user is added as context. Complex types are converted to JSON strings automatically, with an option to swap in a custom serializer.

05
DEEP OPEN-SOURCE ANALYSIS

Getting the events out

The README points anyone who needs data out of ETW to the Microsoft Enterprise Library Semantic Logging Application Block. Its listeners write to the console, a rolling flat file, or databases, which ties ETW into existing log destinations rather than leaving it stranded in the tracing layer.

06
DEEP OPEN-SOURCE ANALYSIS

Editorial conclusion

For .NET shops that want ETW but not the hand-written EventSource, this is a thin layer that turns interfaces into logging sources, with transforms in 2.0 to reshape what gets recorded.

07
DEEP OPEN-SOURCE ANALYSIS

Official sources

08
Community notes

Community notes