Difference Between Debug and Trace

Both Debug and Trace use System.Diagnostics namespace.

Debug

  1. It uses Debug class.
  2. It uses in debug build.
  3. It uses the time of application development.
  4. In Debug mode compiler inserts some debugging code inside the executable.
  5. Debug class works only in debug mode.
  6. Performance analysis cannot be done using Debug.
  7. Debugging uses to find error in program.
  8. For Debug we can use Debug.Write() method.
  9. Debug runs in same thread as main program execute.

Trace

  1. It uses Trace class.
  2. Trace statement includes by default when program compiled into released build.
  3. Trace class is used for testing and optimization even after an application is compiled and released. 
  4. Trace class works in both case Debug mode as well as release mode.
  5. Trace runs in different thread form main program execute thread.
  6. For Trace we can use Trace.Write() method.  
  7. It uses time of application deployment.