Thanks for your response.
I have two Listeners configured, one named "Status" the other named "LogError", both of type "AppEventListener" (my custom defined listener).
So at runtime there should be 2 objects of type AppEventListener, right?
The "Status" Listener is connected to my "StatusMsg" category while the "LogError" Listener is connected to the special category "Logging Errors & Warnings".
Now, in my code, I want to subscribe to the "Status" Listeners Event to get all status Logs and display them, and also to the "LogError" Listeners Event to check the log error messages to handle them differently.
Using your snippet i can successfully access all the Listeners configuration data, but how do i get a reference to the object that got created using this configuration data? I think it should be of type System.Diagnostics.TraceListener
To get a reference to the "Status" Listener (assigned to the "StatusMsg" category) i use the following. But as said, this way i can only access listeners connected to normal categories, Listeners assigned only to any of the 3 special categories, I will not
System.Diagnostics.TraceListener ret = null;
LogWriter logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
foreach (KeyValuePair<string, LogSource> ts in logWriter.TraceSources)
List<System.Diagnostics.TraceListener> tll = (List<System.Diagnostics.TraceListener>)ts.Value.Listeners;
if (tll != null && tll.Count > 0)
foreach (System.Diagnostics.TraceListener tl in tll)
if (tl.Name == "Status")
if (tl is Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper)
ret = ((Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper)tl).InnerTraceListener;