Monday, February 21, 2011

How to log information from inside <CFScript>

HI ,

I am learning to use <cfscript>.

Is there any way I can log some messages or values inside the <cfscript>?

like outside <cfscript> I can use <cflog>, Is there any way or Tag something like that, i can use to print the messages in log file inside >

Thanks

From stackoverflow
  • Unfortunately there isn't. However, what you can do is map a UDF to cflog:

    <cffunction name="doCFLog">
       <cflog attributeCollection=arguments>
    </cffunction>
    

    inside your cfscript call the doCFLog function with the same attributes as you would cflog

    eg. doCFLog(text='sometext', type='warning',application='yes', file='mylog');

    Note: its not a good idea to call your methods/udf etc the same name as an existing function or tag, hence not calling the function "cflog" or "log"

  • ColdFusion 9 added the "writeLog" function which allows you to do this. http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS48D04B65-0694-44e9-9E35-F9D7C9152B6C.html

    CFUser : Thanks Terry for info
    Stephen Moretti : Knew I'd seen something in CF9... typically couldn't see it when I looked. Thanks for the reminder Terry.

0 comments:

Post a Comment