I think CircularTraceListener
is basically flawed. As you've noticed there is a static
m_stream
. But, even worse, when you construct a CircularTraceListener
it passes along the new stream to the base (XmlWriterTraceListener
). This means that although CircularTraceListener
only knows about the last created stream, the base class is potentially using one of many streams. And, of course, if the CircularTraceListener
gets disposed, the base class will dispose the shared m_stream
object.
I'd recommend you'd not base anything from CircularTraceListener
and start from scratch.
update:
I've had much better luck with things like log4net and NLog for things like circular logging.