This example demonstrates how to configure customize the name and GUID of the ETW event source.
The custom log source is implemented in the MyEventSource
class. This class must fulfill the following requirements:
- Inherit the
PostSharpEventSource
class - Be annotated with the
EventSource
andGuid
custom attributes. - Contain a set of predefined methods annotated with an
Event
custom attribute. You can change the method name or any parameter of theEvent
custom attribute, but you can change nor theeventId
parameter and nor the signature of the method for this specific event. These methods exist for the sole purpose of defining the event metadata. They are never invoked directly.
An instance of the new event source class is passed to the constructor of EventSourceLoggingBackend
.
To view the log produced by this example, you need to attach a log collector:
-
Download PerfView from https://www.microsoft.com/en-us/download/details.aspx?id=28567.
-
Execute: perfview.exe collect -OnlyProviders:*MyEventSource
-
Execute this program.
-
In PerfView, click 'Stop collecting', then in the PerfView tree view click 'PerfViewData.etl.zip' and finally 'Events'.