Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Coldfusion 8.0.1 on Windows 2003

Does anyone know a way to manually or programmatically reliably delete or move log files from the \ColdFusion8\logs directory?

Deleting them in Account Admin rarely works without about 30 tries. Archiving them leaves an empty file that makes it hard to visually scan the folder for new issues.

Stopping the CF service is the only sure fire way I have found and that is not an option on production servers.

We tried adding a file date to the log file name hoping CF would let go of the file after some time period but that did not work, the files stay locked by the CF process.

I know there are utilities like unlocker but I think those may kill the cf/jrun process.

Is there any way to stop and restart just the logging process or any other approach?


share|improve this question

4 Answers 4

On Windows I don't know of any way to do this without stopping the service as the process grabs a hold on the file. Something like unlocker may let you delete the file, but, I'm not sure if it would then cause confusion when it tried to rewrite to that file.

share|improve this answer
I think unlocker would probably kill the jrun process so that is not a good option. – kevink Jul 7 '09 at 15:17

When I read your question I thought about log rotation, i.e., the logs would get to be a certain (configurable) size and then be replaced by new files and have their names changed to include a sequence number.

A little Google search turned up this post by Sean Corfield, which describes ColdFusion's built in log rotation. It sounds like it can be configured to help you accomplish what you wish:

In the ColdFusion Administrator, under Debugging & Logging > Logging Settings, you can set the size at which log files rotate and the number of past log files to keep.

Maximum file size (KB) - "When a file reaches this size, it is automatically archived."

Maximum number of archives - "After reaching this limit, files are deleted in order of oldest to newest."

By default, the maximum file size is set to 5000 so whenever a log file reaches (about) 5Mb, it is archived (rotated) and by default the last 10 archives are kept (in addition to the current log).

If you change the settings, it affects any new log files created but does not affect any existing log files - unless you restart ColdFusion.

share|improve this answer
Thanks but unfortunately archiving creates a new empty file (also locked so it is hard to delete). I am looking for a way clear the log files out of the logs directory. – kevink Jul 7 '09 at 15:16
Maybe I don't understand: when the logs are rotated, the old log files should be unlocked, right? Yes, a new log file will be created and begin to fill up, but you should be able to clear the old ones out. – Clint Miller Jul 7 '09 at 15:56
Clint true, but the problem is that I want all log files deleted, not just new empty ones. Seems like it should not require a restart to clear the directory. – kevink Jul 7 '09 at 23:45

ColdFusion locks them. ColdFusion can delete them. Create a custom template to handle your desired log backup and deletion, then add it as a ColdFusion scheduled task.

share|improve this answer
I don't see a way to get CF to delete them, CFFile delete does not work – kevink Sep 20 '09 at 11:37

Steven is right, whenever you want to delete the log files you can run the following code.

You can try following code :

    <cfset logDir ="path of the log directory">
<cfdirectory action="list" directory="#logDir#"  name="qry" filter="*.log">
<cfloop Query="qry">
    <cffile action="delete"  file="#logDir##qry.Name#">
share|improve this answer
Thanks for the tip but it does not work, I get the error: ColdFusion could not delete the file c:\ColdFusion8\logs\application.log for an unknown reason. – kevink Sep 20 '09 at 11:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.