Posted in ColdFusion | Posted on 11-19-2009 | 4,690 views
As my friends will tell me, I'm something of a cflog fiend. I use logging as my primary debugging tool. It's not perfect, but I find it to be especially effective in Model-Glue applications where one request bounces all over the place from controllers to model files to views. The only problem with cflog though is that it can only log text, not complex data. You can always switch to cfdump for that - don't forget that ColdFusion 8 added the ability to dump to a file. While this works, I prefer the "slimness" of a line of text. So when I need to log some complex data, I just use JSON. For example:
2writeLog(file='picard',text='login good for #arguments.username#');
3writeLog(file='picard',text=serializeJSON(userData));
4return userData;


The one thing that I never liked about the CFLog (and I may be off base here) is that you could not specify a location for the log file, only the name, right?
While I write to the CF logs, I sometimes opt for CFDump because of one reason: CF Log cleanup... I have the hardest time deleting log files through CF Administrator. Click delete, say OK, and get back the Log Files screen showing my log file still there, undeleted! A lot of times, during development, I want to start fresh with the log files after doing something that caused a lot of entries, and the server seems to lock the files and prevent deletion of the log files. (Yes, you can shut down the CF service and delete the files, but that's a worse pain.)
Often times, I've figured out that if you just sit there and continuously click the delete button, eventually you can get lucky and have it deleted, but this is a problem I've noticed from CF7 all the way to CF9!
Any thoughts on this, Ray?
Cheers!
Nothing at all wrong with cftrace - I'm just digging cflog more now. ;)
[Add Comment] [Subscribe to Comments]