Accessing listener instances at run time

Topics: Logging Application Block
Feb 2, 2008 at 10:31 PM
All,

I am creating a CustomTraceListener which will enable log entries to be displayed in the UI. The CustomTraceListener will fire of events whith the formatted message, so that any subscriber to those events can display the message where-ever. My issue lies in getting access to the instance of the CustomTraceListener. What I would prefer to do is something along these lines: create a provider mechanism which can return a reference to the instance of the CustomTraceListener that I will create and configure. So when the app initializes it can subscribe the view to the events from the trace listener. Here is the issue I am having: How do I get access to the instance of the custom trace listener? I need to have access to the instance of the trace listener so that the view component can subscribe to the events. I would like to keep the custom trace listener as abstracted as possible from the view components which will subscribe to the events. Is there a way of accessing the collection of listener instances are run time? I know the Logger class has a non-public collection of the instances, but I'd rather use and existing capability before I go and do brain surgery.

Thanks,

Mike