问题描述
我可以在释放模式使用Trace.WriteLine?
Can I use Trace.WriteLine in release mode?
什么是Trace.Write和Debug.Write之间的主要区别是什么?
And what is the main difference between Trace.Write and Debug.Write?
推荐答案
两者都是条件编译使用 [有条件]
属性。
Both are conditionally-compiled using the [Conditional]
attribute.
如果在跟踪
标记在构建定义,然后调用到跟踪
类将导致跟踪输出被写入。默认情况下,跟踪
在调试和释放模式定义。如果该标志没有被定义,不会发生任何事情。
If the TRACE
flag is defined in the build, then calls to the Trace
class will result in trace output being written. By default, TRACE
is defined in both debug and release mode. If the flag is not defined, nothing will happen.
如果在 DEBUG
标记定义,然后调用到调试
类导致输出被写入调试流。默认情况下, DEBUG
在调试模式下只被定义。
If the DEBUG
flag is defined, then calls to the Debug
class result in output being written to the debug stream. By default, DEBUG
is only defined in debug mode.
另一个主要区别在于跟踪很容易定制跟踪监听器,后来你决定想要做跟踪输出。它比调试输出更加灵活,并且通常更适合于记录在生产中的应用。
The other major difference is that with tracing it's easy to customize the trace listeners and decide later on what you want to do with the trace output. It's more flexible than debug output, and generally better suited to logging in a production application.
这篇关于Trace.WriteLine在释放模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!