Trace.WriteLine in release mode?

前端 未结 3 381
盖世英雄少女心
盖世英雄少女心 2021-01-07 22:01

Can I use Trace.WriteLine in release mode?

And what is the main difference between Trace.Write and Debug.Write?

相关标签:
3条回答
  • 2021-01-07 22:27

    DEBUG:

    RELEASE:

    As you see the TRACE constant is enabled in both configs by default

    0 讨论(0)
  • 2021-01-07 22:37

    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.

    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.

    0 讨论(0)
  • 2021-01-07 22:43

    The difference is in Release mode.

    Debug.Write will not be compiled into the code when the DEBUG symbol is not defined, i.e. compiling in Release mode.

    However, Trace.Write will be compiled in both Debug mode and Release mode.

    0 讨论(0)
提交回复
热议问题