What is the difference between debug.write and Trace.write? When should each be used?
+3
A:
Debug.Write
is only effective on builds where the DEBUG
flag is defined, while Trace.Write
is only effective when the TRACE
flag is defined.
Tormod Fjeldskår
2009-04-11 15:00:22
+2
A:
In the typical release build configuration, the Debug
class is disabled and does nothing. Trace
, however, can still be used in the release. You would typically use Debug.Write
for stuff you only need when debugging and which is too verbose for production.
Here's a good article on Debug, Trace
etc: http://www.codeproject.com/KB/trace/debugtreatise.aspx
However, I'm more inclined to use logging libraries like log4net which can be reconfigured on the fly. So you can still turn on full logging in production if you're investigating problems with your application.
Igor Brejc
2009-04-11 15:05:45