Tracing in ASP.NET - Plip's Weblog:

Remember way back to the top of the article, where I showed you an excerpt from the .NET SDK Documentation, it said โ€œTrace statements are processed and displayed only when tracing is enabled.โ€?

It Lies. ;)


Couple of keys for tracing -- one, Tracing writes get executed even if tracing is off, apparently (well, in most cases duh -- you can't very well avoid "lets say youโ€™ve put a large loop in to your page and itโ€™s outputting data to the Trace log so you can debug it โ€“ why do we need to call this when Trace is turned off?" just by having .NET actually follow through on its claim that "Trace statements are processed and displayed only when tracing is enabled." The write is avoided, but the logic's all there) and two, Trace.IsEnabled is the way around that. I'd think a good compiler would compile out the whole Trace slew.