Debugging On Demand in ColdFusion
While I generally do not like to have any type of debugging turned on in a live production environment, for a few Intranet applications, it’s often useful for me to leave debugging on but hidden away. I do this to be able to look at live production page load times, query run times, etc, whenever I need to.
First, there’s my administrator setup. I configure the debugging section so that debugging is enabled, and the “View / Remove Selected IP Addresses for Debug Output” is empty. I use the classic.cfm output format.
Next, there’s the code section. The code is relatively simple and placed in Application.cfm.
1 2 3 4 5 6 7 | <cfparam name="variables.debugging_on" default="false" type="boolean"> <cfif variables.debugging_on is true> <cfsetting enableCFoutputOnly="No" showDebugOutput="Yes"> <cfelse> <cfsetting enableCFoutputOnly="No" showDebugOutput="No"> </cfif> |
Then there’s just the matter of setting the “debugging_on” variable. You can do this based on just about anything you’d like. For example, you could look at the user who is currently logged in and base it on that. One of my applications is written so that if I am the logged in user, and I put a specific variable in the URL, debugging gets turned on.
Be careful how you output debugging in production, giving the user too much information could be quite dangerous to the security of your application.
