Skip to main content
Known Participant
November 19, 2010
Question

log some messages or values inside the <cfscript>

  • November 19, 2010
  • 3 replies
  • 772 views

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

The following code has this error: "coldfusion.tagext.validation.AllowedAttributesException: Attribute validation error for tag CFLOG".

<cffunction name="doCFLog">

   <cflog attributeCollection=arguments>
</cffunction>
doCFLog(text='sometext', type='warning',application='yes', file='mylog');
This topic has been closed for replies.

3 replies

albertkaoAuthor
Known Participant
November 19, 2010

I find this answer:

<cffunction name="doCFLog">

   <cfargument name="text" type="string" default="" required="no">

   <cflog file="mylog" text="#text#">

</cffunction>

doCFLog(text='TotalLines #TotalLines#');

BKBK
Community Expert
Community Expert
November 21, 2010

Your answer is, of course, good. Another idea along the same lines:

<cffunction name="doCFLog">

<cfargument name="logArgs" type="struct">

<!--- No need to cfparam the 'text' argument, as it is compulsory --->

<cfparam name="arguments.logArgs.log"         default="application">

<cfparam name="arguments.logArgs.file"        default="test">

<cfparam name="arguments.logArgs.type"        default="information">

<cfparam name="arguments.logArgs.application" default="true">

<cflog text="#arguments.logArgs.text#"

    log="#arguments.logArgs.log#"

    file="#arguments.logArgs.file#"

    type="#arguments.logArgs.type#"

    application="#arguments.logArgs.application#">

</cffunction>

<cfscript>

args.text = 'sometext';

args.file = 'mylog';

args.type = 'warning';

doCFLog(args);

</cfscript>

done logging.

cfjedimaster
Inspiring
November 19, 2010

I don't believe attributeCollection was valid for built in tags till

cf7. Just change your function to use explicit arguments instead.

Inspiring
November 19, 2010

Is attributescollection a valid attribute for cflog?