View comments | RSS feed

cftrace

Description

Displays and logs debugging data about the state of an application at the time the cftrace tag executes. Tracks runtime logic flow, variable values, and execution time. Displays output at the end of the request or in the debugging section at the end of the request; or, in Dreamweaver MX and later, in in the Server Debug tab of the Results window.

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

Note:   To permit this tag to execute, you must enable debugging in the ColdFusion Administrator. Optionally, to report trace summaries, enable the Trace section.

Category

Debugging tags, Variable manipulation tags

Syntax

<cftrace 
  abort = "Yes or No"
  category = "string"
  inline = "Yes or No"
  text = "string"
  type = "format"
  var = "variable_name"
</cftrace>

See also

cfdump, cferror, cfrethrow, cftry

History

New in ColdFusion MX: this tag is new.

Attributes

Attribute Req/Opt Default Description
abort
Optional
No
  • Yes: calls cfabort tag when the tag is executed
  • No
category
Optional

User-defined string for identifying trace groups
inline
Optional
No
  • Yes: displays trace code in addition to the trace summary display.
  • No
text
Optional

User-defined string or simple variable. Outputs to cflog text attribute.
type
Optional
Information
Matches to the cflog type attribute; displays an appriate icon.
  • Information
  • Warning
  • Error
  • Fatal Information
var
Optional

The name of a simple or complex variable to display.
Useful for displaying a temporary value, or a value that does not display on any CFM page.

Usage

You cannot put application code within this tag. (This avoids problems that can occur if you disable debugging.)

This tag is useful for debugging CFML code during application development.

You can display cftrace tag output in the following ways:

This is an example of a log file entry:

"Information","web-4","04/08/02","23:21:30",   ,"[30 ms (1st trace)]      
[C:\cfusion\wwwroot\generic.cfm @ line: 9] - 
  [thisPage = /generic.cfm]  "
"Information","web-0","04/08/02","23:58:58",   ,"[5187 ms (10)]  
[C:\cfusion\wwwroot\generic.cfm @ line: 14] - [category]
  [thisPage = /generic.cfm] [ABORTED] thisPage "

For a complex variable, ColdFusion lists the variable name and the number of elements in the object; it does not log the contents of the variable.

The following example traces a FORM variable that is evaluated by a cfif block:

Example

<cftrace var="FORM.variable"
  text="doing equivalency check for FORM.variable"
  category="form_vars"
  inline="true">
<cfif isDefined("FORM.variable") AND #FORM.variable# EQ 1>
  <h1>Congratulations, you're a winner!</h1>
<cfelse>
  <h1>Sorry, you lost!</h1>
</cfif>

			  
						  
						  
                   











ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


rbils@amkor.com said on Jul 2, 2002 at 8:53 PM :
Two things here. First, for the TYPE attribute, this is not exactly the same as CFLOG. In CFLOG, there's a "Fatal" type, but not "Fatal Information".

Second, and I think this is a bug, if you specify "Fatal Information" for the TYPE attribute in CFTRACE, it displays a broken image instead of the image it's supposed to display. I'm guessing this is because of the space in the file name. The reason for the failure is because CF is putting a + in between the file name when it should be using a %20 instead. This can be fixed by changing line 154 in the cftrace.cfm template in mxroot/wwwroot/web-inf/cftags to replace the + in the Replace function with a %20:

<cfoutput><table border=0 cellpadding=0 cellspacing=0 bgcolor="white"><tr><td><img src='/CFIDE/debug/images/#Replace(attributes.type, " ", "%20")#_16x16.gif' alt="#attributes.type# type"><font color="orange"><b>[CFTRACE #TimeFormat( st.timestamp, "HH:mm:ss.SSS" )#] [#st.progressiveDelta# ms] [#st.template# @ line: #st.line#] - <cfif st.abort NEQ "">[#st.abort#]</cfif> <cfif st.category NEQ "">[#st.category#]</cfif> <cfif st.text NEQ ""><i>#st.text#&nbsp;</i></cfif></b></font></td></tr></table><cfif st.varName NEQ "">#outFlush_var#</cfif></cfoutput>
rbils@amkor.com said on Jul 2, 2002 at 9:07 PM :
One more bug. The TYPE needs to be changed from "Fatal Information" to just "Fatal" to make it match the CFLOG tag. The reason is the trace.cfm temmplate used by MX uses the CFLOG tag to write out trace info to the cftrace.log file. When it does, and it trys to pass "Fatal Information" for the TYPE, CFLOG sees this as an invalid TYPE, ignores it, and writes the log entry using the default (Information). This is an easy fix - the docs here need to be updated as mentioned above, and line 78 in the trace.cfm template needs to be changed from:

types[4] = "fatal information";

to

types[4] = "fatal";
fricklas said on Dec 4, 2002 at 7:25 AM :
It also seems to always show the tag name CFTRACE with the line number in the CFTRACE tag itself.

For example, running the example from the docs we get:

[CFTRACE 00:51:36.036] [90 ms] [F:\CFusionMX\wwwroot\WEB-INF\cftags\TRACE.cfm @ line: 85] - [Struct Contents] The contents of the struct stEmployee:

not exactly useful information.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/Tags-pt314.htm