Info on tracing in .NET
Note: All methods of tracing mentioned here will work both in release and debug builds.
If you type the following code, you are actually invoking Page.Trace (TraceContext type) object. This object takes care of writing trace messages to trace.axd (page level tracing). For this object to work, make sure trace is enabled in web.config.
Trace.Write("test")
To use trace listeners, use the following code. Using this code, the trace messages will go to any listener you add to the trace listener collection. The messages will not go to trace.axd. The default listener will output the messages to OutputDebugString (normally the output window of IDE). The other options are Eventlog or text file.
System.Diagnostics.Trace.Write("test");
You can also use conditional tracing using the following code. For this code to work, make sure a BooleanSwitch (for e.g. EnableTrace) is set to 1 in web.config under System.diagnostics section.
BooleanSwitch enableSwitch = new BooleanSwitch("EnableTrace", "Some info on switch"); System.Diagnostics.Trace.WriteIf(enableSwitch.Enabled, "test");