Skip to main content
Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.

Writing To The Standard Out / Console Using WriteDump() In Adobe ColdFusion 2021

By Ben Nadel on
Tags: ColdFusion

As I'm starting to modernize my ColdFusion blogging platform, one thing that I am missing terribly from Lucee CFML is the ability to write to the standard out (stdout) and standard error (stderr) streams. In a Docker / containerized context, writing to the output streams is a powerful debugging tool (not to mention a log aggregation technique). A few months ago, I looked at porting the systemOutput() function from Lucee CFML to Adobe ColdFusion; but, I just recently discovered that the CFDump tag and the writeDump() function in Adobe ColdFusion can write directly to the "console" (Standard Out) instead of to the browser. This isn't as seamless as systemOutput(); but, it may just be good enough!

Historically - and by default - the CFDump tag and the writeDump() function output data to the browser. When combined with the CFAbort tag, dumping data continues to be one of the easiest ways to debug a ColdFusion application. However, halting the control-flow of an application isn't always the best thing to do; and, if the processing is taking place in a background / asynchronous thread, outputting to the browser may not even be possible.

In such situations dumping the data to the server's output stream allows data to be debugged without terminating the contextual process. With the CFDump tag and the writeDump() function, we can use the attribute / argument output="console" to direct the dump to the standard out stream:

<cfscript>

	writeDump(
		var = "Testing writeDump() to the console!",
		output = "console"
	);
	cfdump(
		var = "Testing cfdump to the console!",
		output = "console"
	);

	writeOutput( "Done!" );

</cfscript>

If we run this Adobe ColdFusion code and monitor the server's output stream, we'll see this (taken using CommandBox sever log --follow):

[INFO ] Testing writeDump() to the console!
[INFO ] Testing cfdump to the console!

As you can see, both the CFDump tag and the writeDump() function can write the data to the output stream without aborting the current page request.

Lucee CFML NOTE: When you run the same code in Lucee CFML, the value is prepended with the data type, ex [INFO ] string Hello world!. Of course, in Lucee CFML, we can just use systemOutput() so this minor incompatibility is really a non-issue.

This is really minor; but, it's definitely something I'm going to use for debugging as I update my ColdFusion blogging platform!



Reader Comments

What has two thumbs and hopes you leave a comment? This Guy! (Ben Nadel).

Post A Comment

You — Get Out Of My Dreams, Get Into My Blog
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.