BLOG
12 August, 2004
Better than CFDUMP...
Heres a tip that if not better, is at least as handy as cfdump for debugging ColdFusion applications.
There are lots of ways to trace the execution of a ColdFusion request. Originally you could just cfoutput variables and "starting/finishing x" messages to the page. This got better with the advent of cfflush to make sure the messages were included in the output if you hit an exception. The cftrace tag improved things further by automating the flushing, adding Dreamweaver integration and copying to a log file, but (Dreamweaver integration aside - does anyone out there use this, is it good?) you still had to view the web page to get the trace results. If you're building an RIA or web service there's no way to see trace information when you're testing with the client (without the client you can still invoke a cfc method in a browser).
The unix command "tail" outputs the last x lines of a file. If you add the -f option it updates them in real time as lines are appended to the file. On proper Unix machines (like my PowerBook :) tail is built in - on Windows there are many ports.
If you tail -f any of the ColdFusion log files you get a live (no waiting for request to finish) view of anything written to that log. When I'm writing code I use cftrace or cflog to write my trace statements (usually in a function, so that I can change or disable the tracing easily). When it comes to testing and debugging I set up several console windows tailing the various logs, and as requests run I can see exactly what they're up to, even during RIA development.
Log tailing has made it a lot easier for me to test and debug ColdFusion applications, particularly RIAs. A search for cftrace/cflog/tail in Google came up empty, so I thought it was worth mentioning here.
Comments
I've always thought it would be kind of cool if you could have CF talk directly to a console or windows app of some kind. This would only be useful if you worked on the local machine. I never even considered the tail -f approach. That's pretty smart. I may actually consider seeing if I can create a c# app to do the same.
Comment made by Raymond Camden / Posted at Thursday 12 August, 2004 11:08
If your project requires this kind of debugging using C# in the first place as the primary language would give you this capability. CFML as a language and the supporting toolset is not really meant for this calibre of development..
Comment made by Brian LeRoux / Posted at Friday 13 August, 2004 03:08
We use tail all the time to monitor some of our log files - both some of the CF logs and logs our applications write to.
Since we do dev on local machines, it's easy to watch what's going on there as it happens.
Ray, why would you need a C# app? What would it do that tail doesn't?
Comment made by Rob Brooks-Bilson / Posted at Friday 13 August, 2004 04:08
Brian: I disagree. I don't think watching a log is complex at all. For web apps it makes perfect sense. Using a log means you don't clutter up your display. I only mentioned c# as a _client_ to tail the log files, thats all.
Rob: I only mentioned c# as a way to build my _own_ tail, but maybe something a bit more visual. This was mentioned purely as something that would be fun to build, not something really necessary.
Comment made by Raymond Camden / Posted at Friday 13 August, 2004 04:08
I never said its complex. I said ColdFusion tools and the language aren't of the calibre I expect for serious application development and debugging.. having the ability to step through code as it executes is useful.
Comment made by Brian LeRoux / Posted at Friday 13 August, 2004 07:08
-tail f sounds GREAT if your a *nix head...
what can us windorks use ;)?
later
tw
Comment made by tony weeg / Posted at Friday 13 August, 2004 10:08
This is the one I used:
http://unxutils.sourceforge.net/
Comment made by Raymond Camden / Posted at Friday 13 August, 2004 10:08
I think it is better to develop something in C# or ColdFusion for displaying those logfiles in console window or seperate browser window. This way developer will have more control. They can not only display most recent messages but also filter it for a particular type of message.
Comment made by Asif Rashid / Posted at Saturday 14 August, 2004 01:08
Ray: I was thinking of writing a Flash Comm server app to push tail output to a Flash movie - but really the easiest way to monitor the logs on a remote server live would be to have a remote SSH shell on your server and call tail there.
Brian: You seem to be having a bit of a go at CF here for not supporting step-through-code (which it does anyway, though RDS and Homesite/Dreamweaver). Your connection of code stepping and "enterprise class" development is also bit strange to me - the only time I really developed this way was when I started VB programming at Andersen Consulting years ago, I haven't seen it used much anywhere else. Logging and tracing seems to be (according to many authorities) good programming practice.
Tony: Another one to look at might be
HPS Wintail- I noticed it on Google and it seems to have a lot of the highlighting/filtering features people mentioned.
Asif: HPS Wintail aside, don't forget that you can view logs remotely from the CF Administrator (not in real time, of course).
Comment made by Robin Hilliard / Posted at Saturday 14 August, 2004 10:08
I use "cygwin" linux tools on windows. http://www.cygwin.com/
tail -f is is a neat idea... wish I had thought of it.
to filter try:
tail -f "filename" | grep "pattern"
I'm sure Asif's program will work much better though. Let me know when you have it working. :)
Comment made by Lee Howard / Posted at Monday 16 August, 2004 11:08
I haven't tried it yet, but for those eclipse users there's also http://eclipsetail.sourceforge.net/eclipsetail.html.
Comment made by Chris Velevitch / Posted at Friday 20 August, 2004 04:08
Has anyone been able to get eclipsetail to work in 3.0? I assume after it is installed it should be available as a view?
Comment made by Simon Janssens / Posted at Friday 10 September, 2004 09:09
There is another tail-like plugin called Log Watcher (http://graysky.sourceforge.net/). Again I haven't tried it, but it looks more active that EclipseTail.
Comment made by Chris Velevitch / Posted at Thursday 23 September, 2004 01:09
Post Your Comments