User Guide

Table Of Contents
Logging errors with the cflog tag 321
Logging errors with the cflog tag
ColdFusion provides extensive capabilities for generating, managing, and viewing log files, as
described in Configuring and Administering ColdFusion MX. It also provides the
cflog tag which
adds entries to ColdFusion logs.
ColdFusion automatically logs errors to the default logs if you use the default error handlers. In all
other cases, you must use the
cflog tag in your error handling code to generate log entries.
The
cflog tag lets you specify the following information:
A custom file or standard ColdFusion log file in which to write the message.
Text to write to the log file. This can include the values of all available error and cfcatch
variables.
Message severity (type): Information Warning, Fatal, or Error.
Whether to log any of the following: application name, thread ID, system date, or system time.
By default, all get logged.
For example, you could use a
cflog tag in an exception error-handling page to log the error
information to an application-specific log file, as in the following page:
<html>
<head>
<title>Products - Error</title>
</head>
<body>
<h2>Sorry</h2>
<p>An error occurred when you requested this page.
The error has been logged and we will work to correct the problem.
We apologize for the inconvenience. </p>
<cflog type="Error"
file="myapp_errors"
text="Exception error --
Exception type: #error.type#
Template: #error.template#,
Remote Address: #error.remoteAddress#,
HTTP Reference: #error.HTTPReferer#
Diagnostics: #error.diagnostics#">
</body>
</html>