cflog
Description
Writes a message to a log file.
Categories
Related
History
ColdFusion
MX: Deprecated the thread, date,
and time attributes. They might not work, and might
cause an error, in later releases. (In earlier releases, these attributes
determined whether the respective data items were output to the
log. In ColdFusion MX, this data is always output.)
Syntax
<cflog
text = "text"
type = "information|warning|error|fatal"
application = "yes|no"
file = "filename"
log = "log type">
Note: You
can specify this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| application | yes: logs the application name, if it is specified in a cfapplication tag or Application.cfc file. no | Optional | yes |
| file | Message file. Specify only the main part of the filename. 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. If the file does not exist, it is created automatically, with the extension .log. | Optional | |
| log | If you omit the file attribute, writes messages to standard log file. Ignored, if you specify file attribute. Application: writes to Application.log, normally used for application-specific messages. Scheduler: writes to Scheduler.log, normally used to log the execution of scheduled tasks. | Optional | |
| text | Message text to log. | Required | |
| type | Type (severity) of the message: Information Warning Error Fatal | Optional | Information |
Usage
This tag logs 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 extension .log and must be located in the ColdFusion log directory.
Log entries are written as comma-delimited lists with these fields:
type
thread
date
time
application
text
Values are enclosed in double quotation marks. If you specify no for the application attribute, the corresponding entry in the list is empty.
You can disable cflog tag execution. For more information, see the ColdFusion Administrator Basic Security page.
The following example logs the name of a user that logs on an application. The message is logged to the file myAppLog.log in the ColdFusion log directory. It includes the date, time, and thread ID, but not the application name.
<cflog file="myAppLog" application="no" text="User #Form.username# logged on."> For example, if a user enters "Sang Thornfield" in a form’s username field, this entry is added to the myApplog.log file entry:
"Information","153","02/28/01","14:53:40",,"User Sang Thornfield logged on."
Log entries are written as comma-delimited lists with these fields:
type
thread
date
time
application
text
Values are enclosed in double quotation marks. If you specify no for the application attribute, the corresponding entry in the list is empty.
You can disable cflog tag execution. For more information, see the ColdFusion Administrator Basic Security page.
The following example logs the name of a user that logs on an application. The message is logged to the file myAppLog.log in the ColdFusion log directory. It includes the date, time, and thread ID, but not the application name.
<cflog file="myAppLog" application="no" text="User #Form.username# logged on."> For example, if a user enters "Sang Thornfield" in a form’s username field, this entry is added to the myApplog.log file entry:
"Information","153","02/28/01","14:53:40",,"User Sang Thornfield logged on."