跟踪调试VS .NET中的BCL [英] Trace vs Debug in .NET BCL

查看:99
本文介绍了跟踪调试VS .NET中的BCL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,

  • <一个href="https://msdn.microsoft.com/en-us/library/system.diagnostics.debug(v=vs.110).aspx"><$c$c>System.Diagnostics.Debug,和
  • <一个href="https://msdn.microsoft.com/en-us/library/system.diagnostics.trace(v=vs.110).aspx"><$c$c>System.Diagnostics.Trace

基本上是相同的,显着的例外是调试的用法是编出来的一个发布配置。

are largely the same, with the notable exception that Debug usage is compiled out in a release configuration.

当你会用一个而不是其他?这个我已经挖了迄今为止唯一的答案就是你使用调试类生成的输出,你只能看到在调试配置,和跟踪将保持在一个版本的配置,但并没有真正回答我的脑袋的问题。

When would you use one and not the other? The only answer to this I've dug up so far is just that you use the Debug class to generate output that you only see in debug configuration, and Trace will remain in a release configuration, but that doesn't really answer the question in my head.

如果你要测试您的code,为什么你会永远使用调试,因为跟踪可以关闭不用重新编译?

If you're going to instrument your code, why would you ever use Debug, since Trace can be turned off without a recompile?

推荐答案

的主要区别是一个你表明:调试不包括在释放,而Trace是

The main difference is the one you indicate: Debug is not included in release, while Trace is.

预期的差,按我的理解是,开发团队可以使用调试发射,这可能是过于详细(或暴露)的产品的消费者(S)丰富的,描述性的消息,而跟踪的目的是放出该类型的消息被朝检测应用程序更专门面向。

The intended difference, as I understand it, is that development teams might use Debug to emit rich, descriptive messages that might prove too detailed (or revealing) for the consumer(s) of a product, while Trace is intended to emit the kinds of messages that are more specifically geared toward instrumenting an application.

要回答你的最后一个问题,我想不出一个理由使用调试仪器一块code我打算放人。

To answer your last question, I can't think of a reason to use Debug to instrument a piece of code I intended to release.

希望这有助于。

这篇关于跟踪调试VS .NET中的BCL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆