2

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

SteveC
  • 15,808
  • 23
  • 102
  • 173
  • Does your aspect work normally at runtime? Maybe you're not flushing enough to see it all in DbgView/TraceSpy? – ILovePaperTowels Nov 03 '11 at 15:34
  • No, I get the same effect at run-time, i.e. DbgView and TraceSpy only show some of the trace writes, whereas the text logs have all traces – SteveC Nov 04 '11 at 12:07

1 Answers1

2

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?

Carth
  • 2,303
  • 1
  • 17
  • 26
  • Yes ... just noticed a pattern, the 1st, 3rd, etc. call is missing from the DbgView display – SteveC Nov 04 '11 at 12:42
  • Nope ... it was just pure luck. I've ran the same unit test, using NUnit GUI, no VS2010. There is some sort of pattern ... sometime get 4 out of 9, sometimes 5 out of 9, but the two sets are always the same specific traces – SteveC Nov 04 '11 at 12:56