Justin Carter's madfellas.com

ColdFusion 8 Ajax Logger

I thought I'd whip up a quick post about CF8's new "ColdFusion AJAX Logger" which I was playing around with a little bit yesterday. It's basically a floating widget which appears on your pages to give you different levels of logging information about the various JavaScript events that are occuring on your page at run-time. Here's a sample of what some output could look like: First, to enable the Ajax Logger you'll need to do a couple of things. In CF Administrator, go to the Debugging & Logging page and tick "Enable AJAX Debug Log Window". To ensure that your page will have access to the necessary JS resources at run-time you should put the new <cfajaximport> tag somewhere in your code (preferably somewhere at the top where you'll notice it). This will then make the ColdFusion.Log object available to you in your JavaScript which will let you make use of some functions like ColdFusion.Log.debug() for writing debug output to the logger and ColdFusion.Log.dump() for dumping JavaScript objects to the logger. In the screenshot above is an example of ColdFusion.Log.dump() which I used to dump the ColdFusion.Ajax object. You'll notice it looks strangely similar to everyone's favourite <cfdump> tag, and you may also recognise it as the JavaScript Dump function (also available as a jQuery plugin) from Net Grow. Now that you know how to configure CF to enable the use of the Ajax Logger and which functions to call to start logging your debug output, you just need one final step to actually make the logger appear on the page when you are debugging. You can do this two ways;
  • add <cfset url.cfdebug = true> somewhere in your code, or
  • append cfdebug=true to the URL of the page in your browser
Also as a side note, it would be nice if the logger window was resizable to cater for the large amount of info that ColdFusion.Log.dump() spits out. Although I guess there is always FireBug and/or ColdFire :) P.S. Does anyone else get the feeling we've recently gone from having not enough debugging tools to having debugging tool overload?! Haha :P