Server-side Debug using <cfdump>
The ColdFusion <cfdump> tag is very useful when you are trying to debug any ColdFusion code. You simply pass it a variable to dump, and it produces a color-coded output, displaying all the values of the variable. It works for both simple and complex variables.
When using this approach, you first save the contents of the dump of the variable that you want to debug. And then you save the variable containing the dump to a file.
To implement this, you can add the following code to your method.
<cfset sFilePath = expandPath("/#request.siteContext.dsn#/flexdump.html")>
<!--- Save the dump to a variable. Replace [my_variable] with the name of the variable you want to dump. Also change [my_label] to reflect the correct label for the dump--->
<cfsavecontent variable="oDump">
<cfdump var="#arguments#" label="Arguments">
<cfdump var="#[my_variable]#" label="[my_label]">
</cfsavecontent>
<cffile action="write" file="#sFilePath#" output="#oDump#">
In this code, replace [my_variable] with the name of the variable you want to dump. Also change [my_label] to reflect the correct label for the dump.
If you find you are using this piece of functionality quite often, you should consider converting this into a private function in your component, and then call that method.
Comments
There are no comments for this page as yet.
print page
