Using the cftrace tag to trace execution

The cftrace tag displays and logs debugging data about the state of your application at the time the cftrace tag executes. You use it to provide "snapshots" of specific information as your application runs.

This section describes the following topics:

About the cftrace tag

The cftrace tag provides the following information:

A typical cftrace tag might look like the following:

<cftrace category="UDF End" inline = "True" var = "MyStatus" 
text = "GetRecords UDF call has completed">

You can display the cftrace tag output in either or both of the following ways:

The cftrace tag executes only if you select Enable Debugging on the ColdFusion MX Administrator Debugging Settings page. To display the trace results in the debugging output, you must also specify Tracing Information on the Debugging Settings page; otherwise, the trace information is logged and inline traces are displayed, but no trace information appears in the debugging output.

Note: When you use in-line trace tags, ColdFusion sends the page to the browser after all page processing is completed, but before it displays the debugging output from the debug template. As a result, if an error occurs after a trace tag but before the end of the page, ColdFusion might not display the trace for that tag.

An in-line trace messages look like the following:


An in-line trace message

The following table lists the displayed information:

Entry Meaning


The Information icon for the logging severity type

Trace type (severity) specified in the cftrace call; in this case, Information.

[CFTRACE 13:21:11.011]

Time when the cftrace tag executed.

[501 ms]

Time taken for processing the current request to the point of the cftrace tag.

[C:\CusionMX\wwwroot\MYStuff\

mydocs\tractest.cfm]

Path in the web server of the page that contains the cftrace tag.

@ line:14

The line number of the cftrace tag.

[UDF End]

Value of the cftrace tag category attribute.

GetRecords UDF call has completed

The cftrace tag text attribute with any variables replaced with their values.

MyStatus Success

Name and value of the variable specified by the cftrace tag var attribute.

ColdFusion logs all cftrace output to the file logs\cftrace.log in your ColdFusion installation directory.

A log file entry looks like the following:

"Information","web-29","04/01/02","13:21:11","MyApp","[501 ms (1st trace)] [C:\CFusionMX7\wwwroot\MYStuff\mydocs\tractest.cfm @ line: 14] - [UDF End] [MyStatus = Success] GetRecords UDF call has completed "

This entry is in standard ColdFusion log format, with comma-delimited fields inside double-quote characters. The information displayed in the trace output is in the last, message, field.

The following table lists the contents of the trace message and the log entries. For more information on the log file format, see Logging errors with the cflog tag.

Entry Meaning

Information

The Severity specified in the cftrace call.

web-29

Server thread that executed the code.

04/01/02

Date the trace was logged.

13:21:11

Time the trace was logged.

MyApp

The application name, as specified in a cfapplication tag.

501 ms (1st trace)]

The time ColdFusion took to process the current request up to the cftrace tag, This is the first cftrace tag processed in this request. If there had been a previous cftrace tag, the parentheses would contain the number of milliseconds between when the previous cftrace tag ran and when this tag ran.

[C:\CFusionMX7\wwwroot\MYStuff\mydocs\
tracetest.cfm @ line: 14]

Path of the page on which the trace tag is located and the line number of the cftrace tag on the page.

[UDF End]

Value of the cftrace tag category attribute.

[MyStatus = Success]

Name and value of the variable specified by the cftrace tag var attribute. If the variable is a complex data type, such as an array or structure, the log contains the variable value and the number of entries at the top level of the variable, such as the number of top-level structure keys.

GetRecords UDF call has completed

The cftrace tag text attribute with any variables replaced with their values.


View comments in LiveDocs