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.