How can I record * all * ColdFusion scripts and CFCs used?

I want to determine from a large codebase which files are actually being used over a period of time. I need to know about CFM pages and CFCs, and any CFM files, etc.

I know I can get some of this information using logging in application.cfm or using IIS, but I will still skip any include files and any CFCs used.

Is there a way to get the CF to register each file it does? Ideally I would like to keep any new coding to a minimum or just in one place.

Thanks, Ciarán

+1


source to share


2 answers


Hmmm, I think you need to enable debugging and create a custom debug template.

Debug templates are located at: [coldfusiondir] / wwwroot / WEB-INF / debug

Take a look at the code it classic.cfm

uses to render Templates to the screen, and then write some similar code that registers the launch of each template in the appropriate data store.



Note. There is a performance issue (in CFMX6 / 7) with report runtimes and CFCs, so make sure this option is disabled and any associated code is removed.

Infact, if it needs to work in a Live environment (not ideal) make sure you split your own template down to the minimum required code to do just this logging.

+4


source


The debug templates approach will work, but will only work if debugging is enabled. If your codebase is large and cumbersome and the only place you should be collecting this information is in live, then make sure these templates don't output anything.

Also, your CFC calls will slow down quite a bit. Be very careful to understand how this destroys your servers.

Personally, I would just update the server level structure with just the filename.

<cfparam name="server.st_FileLog" default="#structNew()#">
<cfparam name="server.st_FileLog[thisFile]" default="1">

      



These two lines in Application.cfc or Application.cfm can just do it.

Then just add a separate piece of code that dumps out the code.

<cfoutput><code>#structKeyList(server.st_FileLog,chr(13))#</code></cfoutput>

      

-2


source







All Articles