I ran across a need to periodically archive my CFMX 7's logs. I initially thought about using the cffile tag and doing some combination of copy & rename actions. I quickly realized that trying to do operations on an active log file would not work. Then I remembered that wonderful coldfusion.server.ServiceFactory and the rollLog method of the LoggingService. This nifty function archives or "rolls" the log of the logfile name passed into it: rollLog("full_path_name_to logfile name plus the logfile_name"). Creating a scheduled task that periodically calls this type of function is an easy way to keep the active logs from growing too large and still maintain the former log's contents.
Here's a code example. |