Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

log some messages or values inside the <cfscript>

New Here ,
Nov 18, 2010 Nov 18, 2010

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');
TOPICS
Getting started
709
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 18, 2010 Nov 18, 2010

Is attributescollection a valid attribute for cflog?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 19, 2010 Nov 19, 2010

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2010 Nov 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#');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 21, 2010 Nov 21, 2010
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources