Trace vs Debug in .NET BCL

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

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.

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.

Hope this helps.


The only difference between trace and debug is that trace statements are included by default in the program when it is compiled into a release build, whereas debug statement are not.

Thus, the debug class is principally used for debugging in the development phase, while trace can be used for testing and optimization after the application is compiled and released.


Debug is used to pure debugging purposes. It emits rich messages in debug execution (debug mode).

Trace helps in application debugging, bug fixing, and profiling (after release).

The Debug class is of no use in release mode.


For highly performance sensitive code blocks, leaving Trace compiled-in but disabled might make a performance difference.