How to Automatically Detect That Debugging Is Active in Production
By now you should know that it's best practice to keep debugging turned off on production servers. Even when debugging is restricted by IP, ColdFusion busily goes about collecting debugging information for every page request, even though it's not displayed on the screen. All this extra activity tends to slow down the server a bit, particularly if you have "Report Execution Times" selected. Under load, having debugging turned on can have a serious impact on performance. Even in development, turning on "Report Execution Times" can have a significant impact if alot of developers are sharing one dev box.
So you know you should have it turned off in production, but inevitably you're going to need to debug something in production sooner or later, and turn that evil debugging switch back on for a moment. Occasionally you're going to forget to turn it back off. Occasionally the wrong person gets access to the CFAdmin and turns it on just because they don't know any better. However it happens - chaos, anarchy, and mass confusion are likely not far behind.
Wouldn't it be nice to be able to automatically detect that debugging it turned on and send yourself a notification or alert so you can shut it back off? Oh, but you can! Here are a couple of code snippets that you can drop into your Application.cfm or Application.cfc file to fire off an alert to yourself.
Or, if you want to get a little more complicated and detect that template execution times are being calculated (maybe on a busy dev box), you can try this one:
Both of these should work in CF6 and above, but I've only tested them on CF8.