Call a TraceListener from CustomTraceListener

Topics: Logging Application Block
Dec 1, 2009 at 2:35 PM

Is it possible to call a TraceListener from my CustomTraceListener?

I have a CustomTraceListener and will buffer log messages. Once the buffer limit is crossed, the message will be sent to another TraceListener.

Thus suppose I want to send 100 messages at once to a FlatFileTraceListener, I'll keep them in buffer and then once the threshold is reached they will be sent to the FlatFileTraceListener.

One way is to inherit the FlatFileTraceListener and implement the buffering logic in my Custom Listener. But this will be specific to FlatFileTraceListener.

Tomorrow if FlatFileTraceListener is replaced by EventLogTraceListener it should work.

The TraceListener name can be sent as a parameter to the CustomTraceListener.

I need pointers to invoke a TraceListener within another tracelistener.

Trying to implement something like this:

Similar to "BufferingForwardingAppender" from Log4Net. I can work out the buffering logic.

I just need inputs on how can call one TraceListener from another?




Dec 1, 2009 at 10:50 PM

You can opt to call the Logger.Write inside the custom tracelistener.  The category to where it will be logged will be parameterized (by adding in the Attributes collection property) and will determine to what trace listener it will pass the buffered messages.  


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.