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:
var userData = maf.login(arguments.username, arguments.password);
writeLog(file='picard',text='login good for #arguments.username#');
writeLog(file='picard',text=serializeJSON(userData));
return userData;
Archived Comments
probably useless, but wouldn't wddx let you log complex data?
I find JSON easier to read than WDDX.
Now that CFDump can be written to a file, I feel like it's functionality is complete :) I think it even appends to files (during the dump process).
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?
Yep, cflog only logs to files within the CF logs folder. Obviously you can use cffile instead.
This might be slightly off topic, so I apologize ahead of time...
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?
I've seen that too. :( It seems mainly to be an issue with the default logs - so I'm wondering if its just hard to get a clean lock on the file to perform the delete.
I am surprised Raymond. You are the maintainer of Coldfire Firefox plugin. I would have expected that you use <cftrace/> to debug text/complex data with ColdFire? True that you don't get the disk logging that you can review at a later date, but being able to sprinkle in <cftrace var="somevar"/> and then see it expanded at the bottom of my screen is awfully nice.
Cheers!
I was one of the two creators of ColdFire, but Nathan Mische is now the maintainer.
Nothing at all wrong with cftrace - I'm just digging cflog more now. ;)
on an only slightly related issue. I have found that in CF8 if you use trace in a cfc which is called via Ajax it throws an exception "Debugger not found" I don't know if this is a known issue or if I have configured something incorrectly.
Have you tried it with CF9? I'd suggest doing so - and if you replicate it - file a bug report.
Tested trace in cf9, no error thrown but trace is ignored and not written to trace.log. writelog appears to work fine.
Spoke too soon. If you have "enable request debugging on" in cfadmin the ajax call fails when you have a trace even if inline is false. If you have enable request debugging off the ajax call works but the trace is not written to the tracelog.
I have explained this in a bit more detail: http://blog.vawterconsultin...
Hi,
I am facing a problem in log file, in our application. Logs are deleting itself, is there any size constraint for log files. The deleted logs were important for tracing a issue, is there any way to get back logs which are deleted
There is a feature in CF to delete logs. See the logging settings in the admin.
Hi ray, I am using CFLOG and Coldfsuion10, I want to Log the logs in my external file specified by me the location.
It is unable to doing it, How can i do that, I am using the file attribute to it and using expandpath to locate the folder and log the issues there, but it is not doing that
CFLOG only logs to the main CF logs directory. If you want similar behavior outside of that dir, you need to use cffile.