Highlighted

How to write out a log file?

Engaged ,
Oct 08, 2015

Copy link to clipboard

Copied

I have this function below and I tried to write the result of query to log file but it failed every time I ran. the CFLog tag as third line from the bottom. Any suggestion is much appreciated.

<cffunction name="getCommonSpotPages" access="public" returnType="query">

  <cfset var qryCSPages = queryNew("")>

  <cftry>

  <cfquery name="qryCSPages" datasource="#application.sitemap.sDSN#">

  select p.ID, s.subsiteURL, p.filename, p.DateContentLastModified, u.publicFileName, p.uploaded as bIsUploaded, s.uploadURL,

  (select fieldValue from data_fieldValue dfv where p.ID = dfv.pageID and dfv.fieldID = #application.sitemap.nPriorityFieldID# and dfv.versionState = 2 ) as nPriority,

  (select fieldValue from data_fieldValue dfv where p.ID = dfv.pageID and dfv.fieldID = #application.sitemap.sFrequencyFieldID# and dfv.versionState = 2 ) as sFrequency

  from SitePages p

  join SubSites s

  on p.SubSiteID = s.id

  left join UploadedDocs u

  on p.id = u.pageID

  where (p.expDate is null

  OR p.expDate > getdate())

  and p.pageType = 0 <!--- uploaded documents and content pages only --->

  and p.approvalStatus <> 1 <!--- // exclude inactive pages --->

  and s.siteState <> 0 <!--- // exclude inactive subsites --->

  and s.subsiteURL not like '%training%' <!--- specify all pages inside of the subsite to be exlcuded from the sitemap --->

  and s.ID not in (<cfqueryparam value="#application.sitemap.lstExcludeSubsites#" cfsqltype="CF_SQL_INTEGER" list="yes" /> ) <!--- // exclude particular subsites --->

  order by p.ID desc

  </cfquery>

  <cfcatch><cfdump var="#cfcatch#"></cfcatch>

  </cftry>

  <cflog text="#qryCSPages#" type="Information" file="queryPages">

  <cfreturn qryCsPages>

</cffunction>

All the tmpResult.sql does is print the SQL that was run from within the query.

You cannot tell CF where to save logs.  They are available at [DRIVE]/cfusion/logs - go there and look for your log.  It can also be accessed via CFAdmin, under DEBUGGING AND LOGGING.

HTH,

^_^

Views

290

Likes

Translate

Translate

Report

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

How to write out a log file?

Engaged ,
Oct 08, 2015

Copy link to clipboard

Copied

I have this function below and I tried to write the result of query to log file but it failed every time I ran. the CFLog tag as third line from the bottom. Any suggestion is much appreciated.

<cffunction name="getCommonSpotPages" access="public" returnType="query">

  <cfset var qryCSPages = queryNew("")>

  <cftry>

  <cfquery name="qryCSPages" datasource="#application.sitemap.sDSN#">

  select p.ID, s.subsiteURL, p.filename, p.DateContentLastModified, u.publicFileName, p.uploaded as bIsUploaded, s.uploadURL,

  (select fieldValue from data_fieldValue dfv where p.ID = dfv.pageID and dfv.fieldID = #application.sitemap.nPriorityFieldID# and dfv.versionState = 2 ) as nPriority,

  (select fieldValue from data_fieldValue dfv where p.ID = dfv.pageID and dfv.fieldID = #application.sitemap.sFrequencyFieldID# and dfv.versionState = 2 ) as sFrequency

  from SitePages p

  join SubSites s

  on p.SubSiteID = s.id

  left join UploadedDocs u

  on p.id = u.pageID

  where (p.expDate is null

  OR p.expDate > getdate())

  and p.pageType = 0 <!--- uploaded documents and content pages only --->

  and p.approvalStatus <> 1 <!--- // exclude inactive pages --->

  and s.siteState <> 0 <!--- // exclude inactive subsites --->

  and s.subsiteURL not like '%training%' <!--- specify all pages inside of the subsite to be exlcuded from the sitemap --->

  and s.ID not in (<cfqueryparam value="#application.sitemap.lstExcludeSubsites#" cfsqltype="CF_SQL_INTEGER" list="yes" /> ) <!--- // exclude particular subsites --->

  order by p.ID desc

  </cfquery>

  <cfcatch><cfdump var="#cfcatch#"></cfcatch>

  </cftry>

  <cflog text="#qryCSPages#" type="Information" file="queryPages">

  <cfreturn qryCsPages>

</cffunction>

All the tmpResult.sql does is print the SQL that was run from within the query.

You cannot tell CF where to save logs.  They are available at [DRIVE]/cfusion/logs - go there and look for your log.  It can also be accessed via CFAdmin, under DEBUGGING AND LOGGING.

HTH,

^_^

Views

291

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 08, 2015 0
LEGEND ,
Oct 08, 2015

Copy link to clipboard

Copied

You are sending a query object (complex) to a log as a string (simple).  If you REALLY want all of that information in a log file (if it's a lot of data, I wouldn't), you have to loop the query (if more than one record is returned) and spell out each column for each iteration.

HTH,

^_^

EX

<cfoutput query="qryCSPages">

<cflog text="#ID#: #subsiteURL# - #filename# - #DateContentLastModified# - #publicFileName# - #blsUploaded# - #uploadURL#." type="information" file="querypages" />

</cfoutput>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2015 0
Engaged ,
Oct 08, 2015

Copy link to clipboard

Copied

I've modified the query with a result attribute and log the SQL property as followed but it's still not generating any log. By the way, is there a way to specify where the log file will be created? I do a search for queryPages and nothing was found.

<cflog text="#tmpResult.SQL#" type="Information" file="queryPages">

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2015 0
LEGEND ,
Oct 08, 2015

Copy link to clipboard

Copied

All the tmpResult.sql does is print the SQL that was run from within the query.

You cannot tell CF where to save logs.  They are available at [DRIVE]/cfusion/logs - go there and look for your log.  It can also be accessed via CFAdmin, under DEBUGGING AND LOGGING.

HTH,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2015 0
Engaged ,
Oct 08, 2015

Copy link to clipboard

Copied

Thanks!  I found the log.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2015 0
Advocate ,
Oct 08, 2015

Copy link to clipboard

Copied

If you want more control of your logs (I highly recommend this for all production applications) then learn up on log4j -- this is what cflog uses underneath the covers. I've learned over time that proper and abundant logging is as important as proper and abundant testing for supporting a system.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2015 1