views:

159

answers:

2

Hi everyone.

I am looking to determine from a large code base, what files are actually being used over a period of time. I need to know about CFM pages and CFCs as well as any included CFM files etc.

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

Is there any way to get CF to log every file it executes? Ideally I would like to keep any new coding to a minimum or just in one place.

Thanks, Ciarán

+2  A: 

Hmmm, I think you'll need to turn on debugging and create a custom debug template.

The debug templates are in: [coldfusiondir]/wwwroot/WEB-INF/debug

Have a look at the code which classic.cfm uses to display Templates to screen, and then create some similar code which logs each template run to a suitable data store.

Note: there is a performance issue (in CFMX6/7) with Report Execution Times and CFCs, so make sure you have that setting disabled, and any related code removed.

Infact, if this is to be running in a Live environment (not ideal), then make sure you strip down your custom template to the minimum necessary code to perform just this logging.

Peter Boughton
This is the best solution I have heard so far. However, it requires a fair bit of work and I may post back here when I manage to implement it.
Ciaran Archer
A: 

The approach using the debug templates will work, but will only work if you have debugging enabled. If the code base is large an unwieldy and the only place you have to collect this info is live then make sure those templates aren't outputting anything.

Additionally your CFC calls will slow down quite a bit. Be very careful to see how this destroys your servers.

Personally I would just have it updating a server level structure with nothing more than the filename.

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

Those two lines in Application.cfc or Application.cfm might just do it.

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

<cfoutput><code>#structKeyList(server.st_FileLog,chr(13))#</code></cfoutput>
Stewart Robinson
Application.cfm/c will run once per request - i.e. it does not run for files accessed via cfinclude/cfobject.
Peter Boughton
Yes, the once-per-request issue is the big drawback with this. I would be great if you could switch this type of logging on in CF Admin for a few hours and then parse your log file afterwards? Maybe in CF 9 :)
Ciaran Archer