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("")>
<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
<cflog text="#qryCSPages#" type="Information" file="queryPages">
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.
<cflog text="#ID#: #subsiteURL# - #filename# - #DateContentLastModified# - #publicFileName# - #blsUploaded# - #uploadURL#." type="information" file="querypages" />
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">
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.
Thanks! I found the log.
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.