ColdFusion Debugging

ColdFusion provides a number of debugging tools to assist us in troubleshooting problem areas. Problem areas could be anything from strange results being output from a query, to a slow running template.

ColdFusion's debugging tools, provides us with extra information that we (and our users) don't normally see when visiting the website.

When running a debugger, you should attempt to do so in a development environment. Obviously, this makes sense if you're only in development mode anyway, but, if you're debugging an issue that's occuring in a production environment (where real users are impacted), you should really try recreating the issue on your development environment. Having said that, there are ways of restricting debug output so that your users aren't affected.

The following ColdFusion tools/tags can be useful for debugging your applications:

Below is an overview of each.

The <cfdump> Tag

The <cfdump> tag is a very handy debugging tool for ColdFusion developers. It allows you to output (or "dump") the contents of your variables on the screen. You can use this on any variable, regardless of it's type — arrays, structures, query objects etc

The great thing about <cfdump> is it's ease of use. The syntax is as follows:

Example of Usage

It's just as easy to use <cfdump> on a complex object as it is on a simple variable. Therefore, to give you a better idea of how <cfdump> can help you visualize your objects, I will use a query object for this example.

First, lets create a query object. We do this with the <cfquery> tag:

A <cfdump> of the above query would like something like this:

query
  FIRSTNAMEINDIVIDUALIDLASTNAMEUSERNAME
1Fred1Flinstonefreddo
2Homer2Simpsonhomey
3Homer3Brownnotsofamous
4Ozzy4OzzbourneSabbath
5Homer5Gainnoplacelike

The <cfabort> Tag

It can sometimes be handy placing a <cfabort> tag immediately after your <cfdump>. This way, you prevent the application from doing any further processing until you've decided whether the results of the <cfdump> are correct or not. If you decide the results of the <cfdump> are correct, you can continue to step through the page, placing <cfabort> (and/or <cfdump>) at logical points so that you can get a "snapshot" of the state that the application is in at a particular point.

Debugging Settings (via ColdFusion Administrator)

The ColdFusion Administrator provides a number of debugging options for developers. You can find these options under the Debugging & Logging icon on the left menu. The first option is Debugging Output Settings. This allows you to specify what debug info should be displayed and how.

The Debugging IP Addresses option lets you restrict the debug output to specific IP addresses if required. This is useful if you are debugging in a production environment and don't want your users to see the debugging output.