cflog

Description

Writes a message to a log file.

Category

Data output tags

Syntax


<cflog text = "text"

  log = "log type"

  file = "filename"

  type = "message type"

  thread = "thread ID yes or no"

  date = "date yes or no"

  time = "time yes or no"

  application = "application name yes or no"> 

See also

cfcol, cfcontent, cfoutput, cftable

Attributes

Attribute
Description
text
Required. The message text to log.
log
Optional. If you omit the file attribute, specifies the standard log file in which to write the message. Ignored if you specify a file attribute. Valid values are:
  • Application    Writes to the Application.log file, normally used for application-specific messages.
  • Scheduler    Writes to the Scheduler.log file, normally used to log the execution of scheduled tasks.
file
Optional. Name of the message file. Log files must have the suffix .log. Specify only the main part of the filename, without the .log suffix. For example, to log to the Testing.log file, specify "Testing":
The file must be located in the default log directory. You cannot specify a directory path. The file is created automatically if it does not exist.
type
Optional. The type (severity) of the message. Valid values are:
  • Information (default)
  • Warning
  • Error
  • Fatal Information
thread
Optional. Specifies whether to log the thread ID. The thread ID identifies which internal service thread logged a message. Since a service thread normally services a CFML page request to completion, then moves on to the next queued request, the thread ID serves as a rough indication of which request logged a message. Leaving thread IDs turned on can help diagnose patterns of server activity. Valid values are:
  • Yes (default)
  • No
date
Optional. Specifies whether to log the system date.Valid values are:
  • Yes (default)
  • No
time
Optional. Specifies whether to log the system time.Valid values are:
  • Yes (default)
  • No
application
Optional. Specifies whether to log the application name if one has been specified in a cfapplication tag.Valid values are:
  • Yes (default)
  • No

Usage

The cflog tag lets you log custom messages to standard or custom log files. You can specify a file for the log message or send messages to the default application or scheduler log. The log message can include ColdFusion expressions. Log files must have the suffix .log and must be located in the ColdFusion log directory.

Log entries are written as comma-delimited lists with these fields:

Values are enclosed in double quotation marks. If you specify No for the thread, date, time, or application, the corresponding entry in the list is empty.

You can disable cflog tag execution. For more information, see the ColdFusion Administrator, Basic Security page.

Example

The following tag logs the name of a user who logs on an application. The message is logged to myAppLog.log in the ColdFusion log directory. It includes the date and time, but not the application or thread ID.

<Cflog file="myAppLog" application="No" Thread="No" 

  text="User #Form.username# logged on.">

If the user enters "William Thornfield" in your form's username field, the following entry is added to the end of the myApplog.log file:

"Information",,"02/28/01","14:53:40",,"User William Thornfield logged on."



Banner.Novgorod.Ru