I'm trying to attach a listener to a running process which uses an EventSource
to trace processing events. I've gotten as far as creating my own listener by inheriting from EventListener
and (presumably) need to call EnableEvents
to begin receiving information.
The first argument to all the overloads is the EventSource
to configure and send messages from, but I am unclear how to compose that instance when it needs to identify a source of events in the external process.
I'm just knocking this together as a proof-of-concept, so the code runs in a Console application and the TestEventListener
just tries to write the event to the Console window.
EventSource source = null;
using (var listener = new TestEventListener())
{
listener.EnableEvents(source, EventLevel.Verbose);
Console.ReadKey();
}
Unfortunately, the EventListener class does not talk cross-process, or even across AppDomains. That wasn't the purpose of the EventListener class.
Instead, I recommend you use the upcoming (and most likely will be the official supported ETW "reader" library from MSFT) --
http://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.TraceEvent
While you're at it, check out -- http://oculus.codeplex.com/ (this is very similar to TraceEvent, but has a bunch of different generate code special windows events)
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