为什么 DbgView 缺少一些跟踪写入,但在测试运行程序中可以看到跟踪
谁能解释为什么 DbgView 错过了我的一些跟踪写入?
我正在使用 Enterprise Library 5.0 日志记录块以及从 EntLib CustomTraceListener
派生的跟踪侦听器,如下所示...
[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());
}
}
}
我可以在 VS2010 中的 Resharper 测试运行程序和NUnit GUI 测试器。
我还可以将跟踪发送到平面文件侦听器,这会捕获所有跟踪写入, 但是当我使用 DbgView(以及 TraceSpy) 时,仅显示一些跟踪。
另一个问题是我使用 PostSharp 通过属性将日志记录作为一个方面添加,而不是直接在业务代码中添加
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您运行另一个应用程序并且也捕获部分调试流量时,我已经看到这种情况发生。如果您正在运行一个应用程序并使用 VS2010 调试某些组件,您将看不到任何调试输出被路由到 IDE 而不是 DebugView。如果您同时在同一个机器上测试客户端服务器应用程序,这会很方便,但可能会导致您所描述的问题。除此之外,我只需确保从“捕获”菜单中选中“捕获全局 Win32”(我已经看到,即使我没有预料到它会产生影响)。
丢失的消息总是相同的吗?
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?