Search code examples
debuggingenterprise-librarypostsharp

Why is DbgView missing some trace writes, but the traces can be seen in test runners


Can anyone explain why DbgView misses some of my trace writes ?

I'm using the Enterprise Library 5.0 logging block with a trace listener deriving from the EntLib CustomTraceListener, as below ...

[ConfigurationElementType(typeof(CustomTraceListenerData))]
public class DebugTraceListener : CustomTraceListener
{
    public override void Write(string message)
    {
        Debug.Write(message);
    }

    public override void WriteLine(string message)
    {
        Debug.WriteLine(message);
    }

    public override void TraceData(TraceEventCache eventCache, string source, 
                                 TraceEventType eventType, int id, object data)
    {
        if (data is LogEntry && Formatter != null)
        {
            WriteLine(Formatter.Format(data as LogEntry));
        }
        else
        {
            WriteLine(data.ToString());
        }
    }
}

I can see all the trace in both the Resharper test runner in VS2010, and in the NUnit GUI tester.

I can also send the trace to a flat file listener and this captures all the trace writes, BUT when I use DbgView (and also TraceSpy) only some of the trace is being shown.

The other wrinkle is I'm using PostSharp to add the logging as an aspect, via attribute, rather than directly in the business code


Solution

  • I've seen this happen when you have another application running that is also capturing some part of the debug traffic. If you're running an application and have VS2010 debugging some component you won't see whatever debug output is being routed to the IDE instead of DebugView. This can be handy if you're testing client-server applications on the same box at the same time but can cause the issue you describe. Short of that I'd just make sure that Capture Global Win32 is checked from the Capture menu as well (I've seen that make a difference even when I wouldn't have expected it to).

    Are the missing messages always the same ones?