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

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

问题描述

好像是

大致相同,除了调试用法在发布配置中编译出来的显着例外.

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

你什么时候会使用一个而不是另一个?到目前为止,我挖出的唯一答案就是您使用 Debug 类生成仅在调试配置中看到的输出,并且 Trace 将保留在发布配置,但这并不能真正回答我脑海中的问题.

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.

如果您要检测代码,为什么要使用调试,因为无需重新编译即可关闭跟踪?

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

推荐答案

主要区别在于您指出的区别:Debug 不包含在发布中,而 Trace 包含.

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

据我所知,预期的区别在于,开发团队可能会使用 Debug 发出丰富的描述性消息,这些消息可能对产品的消费者来说过于详细(或透露),而 Trace 旨在发出更专门用于检测应用程序的消息类型.

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.

为了回答您的最后一个问题,我想不出使用 Debug 来检测我打算发布的一段代码的理由.

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.

希望这会有所帮助.

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

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