Written on 2 December 2014, 10:55pm
1. Custom templates for request debug output
Use case: you want to temporarily enable debug output in a production environment (ex – to determine the cause of a specific performance problem), but you obviously don’t want the users to see the debug information.
– restrict debug output to your IP only (if you know exactly who is behind your IP), but it will still introduce a performance problem (the IP has to be checked for every request)
– create a custom debug template (*) – example
logging.cfm instead of
classic.cfm and log all the details you need instead of outputting
– create an empty debug template (
silent.cfm), then create a component with a main logging method based on the
classic.cfm debug template. Call this main method
onRequestEnd to log all the needed details.
(*) A custom debug template can be created and placed in the
WEB-INF/debug ColdFusion folder. The
classic.cfm template can be used as starting point.
More info: http://www.bennadel.com/blog/116-finding-template-execution-stack-in-coldfusion.htm
2. When a ColdFusion template cannot be found
onMissingTemplate and return a 404 HTTP error code. Let the web server handle the error:
<cffunction name="onMissingTemplate"> <cfargument name="targetPage" type="string" required="true"/> <cfheader statuscode="404" statustext="Not Found"> </cffunction>