Debugging ColdFusion the smart way

Today I want to talk about how to debug a ColdFusion application the smart way, this doesn't mean that it is the only way. It means that it is by all intent and purpose smart because you get to see more of what and how something happens.

So what is the smart way you ask?

Well before I answer that I will talk about other means that do the job, but it isn't really that effective. And I mean it is not effective because you only see the end result and not what caused the issue, and that is by using the cfdump tag.

It is useful to use and can help in some areas, but the ultimate debugging solution is to use line debugging and as you will see it is more powerful than you might imagine, and yet extremely easy to setup and use.

Now I am a huge fan of cfeclipse and all the tools that can be added in that IDE to get my job done without leaving the environment, and the biggest addition to this is by Adobe themselves and can be downloaded from Download the ColdFusion 8 Extensions for Eclipse.

Setting that up in Eclipse is easy enough, however if anyone wishes to contact me I will explain how to do it if you get stuck.

Once it is installed into cfeclipse the first thing you will need to do is setup the RDSeclipse_rds  configuration, and this is easily done as shown in the image to the right. Just enter the information to your server in here and to a test to make sure it is configured correctly and that's it. You might also need to log into the ColdFusion administrator and select the line debugging to enabled in there before you do the test debugger, but the testing of the connection just makes sure that we can connect to the server via RDS.

So once that is done we now can head on over to the next area of interest, and that is to be able to select what variables we can see in the ColdFusion debugger. By default there isn't much selected and it is just setup to give you the basics, by going to the Window->Preferences->ColdFusion->Debug Settings within Eclipse you can turn on or off the variables that you wish to be able to see or not see that is relevant to you.

Once we have done that we can now setup a debugging profile that can be used per project, if you are like me I have many local and remote servers that I need to setup as well, so make sure that you add an RDS connection per server that you wish to connect to as well.

eclipse_debug_setupBy selecting Debug Configuration as shown in the below image we can then setup a few  projects, this will enable us to then run that project an be ready to do our debugging.

Once you have selected that a new window will pop up and you should see on the left hand side ColdFusion Application listed in the navigation there, to setup a new debug profile we will Right Mouse Button click and select new. On the right hand side of this window you will then get a few options to select from, and most are very straight forward if you have installed ColdFusion on your machine locally. So the first thing to do is to give the profile a name, this will help identify what the profile is in relation to and I usually name it with a reference with the project name that I am developing with.

The debug URL is fairly straight forward from here, as this is the URL that you would type into the browser to access the ColdFusion application from within the browser. The last thing that you need to change if you have setup multiple RDS configurations as described above, is to select which RDS server you are going to connect to. If you have only setup one this will be the default one displayed, so no need to change this setting at this point in time.

You can then do one of two things from this point, and that is select close or debug. If you select debug at this point then the debugger will be started, selecting close will close the window without starting the debugger.

That's it for this part and feel free to have a play around from here, next time I will go into a bit more depth on how to use the line debugger and so of the options that are available.