Trace.WriteLine in release mode?

前端 未结 3 400
盖世英雄少女心
盖世英雄少女心 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条回答
  •  Happy的楠姐
    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.

提交回复
热议问题