Copy link to clipboard
Copied
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');
Copy link to clipboard
Copied
Is attributescollection a valid attribute for cflog?
Copy link to clipboard
Copied
I don't believe attributeCollection was valid for built in tags till
cf7. Just change your function to use explicit arguments instead.
Copy link to clipboard
Copied
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#');
Copy link to clipboard
Copied
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.