1

Closed

Using TestServer results in plethora of TraceListeners

description

Every time you use a TestServer in a unit test, another TraceListener is added to Trace.Listeners. This causes a substantial buildup of duplicate tracing.

Workaround is periodically call Trace.Listeners.Clear()
Closed Mar 2 at 9:41 PM by mgirgin

comments

pruett wrote Nov 30, 2015 at 7:01 AM

This issue is pretty frustrating from a unit test perspective. The workaround of calling Trace.Listeners.Clear() will stop all other test output as well.

A modification to the workaround that i required is...
 Trace.Listeners.RemoveAt(Trace.Listeners.Count-1);
As far as I know trace listeners are only appended to the Trace.Listeners collection.