How to read ColdFusion log files directly from your app
Written on 16 October 2011, 01:41am
Tagged with: coldfusion, logging
CFLOG
is a very useful tool for debugging. Along with CFDUMP
, it is probably one most used tags in development 🙂
Logging with CFLOG
is extremely simple:
<cflog file="myLogFile" text="#TimeFormat(Now(),'hh:mm:ss.l')#: log message" />
I am usually prepending the timestamp to get the milliseconds (by default, CF only logs the time down to the seconds):
"Information","web-261","10/13/11","06:03:21","APP","06:03:21.319: log message"
About the other attribute of the CFLOG: file, the CF documentation says:
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.
The log file is created inside the ColdFusion default log directory. You can see the content of this file using the ‘Log files’ screen of your CF Admin interface:
But what do you do when you don’t have access to the CF Admin interface? Luckily, you can still see the contents of your log file. You just have to locate the log folder contents and then output the log file contens, as the following script shows:
(more…)
- Likes (1)
- Comments (2)
-
Share