ColdBox 2.6.2 Bug: Log File Paths

ColdBox 2.6.2 Bug: Log File Paths

Posted by Brad Wood
Jan 01, 2009 08:37:00 UTC
Here's a quick note concerning a quirk in the newly released ColdBox 2.6.2 that has a small chance at affecting you. We installed the latest version on our dev server yesterday and upon initializing the framework for the first time were greeted with an odd error while attempting to create the ColdBox logging directory.The error left the framework in a limbo state and made it a little tricky to step through and root out the cause. The message was something along the lines of access denied creating folder "D:/logs/". This made perfect sense since the D: drive on our dev server is a CD-ROM drive. The log files should have been going to our E: drive. One of the things I like about ColdBox is that you can set up your default settings for the app and then override them as necessary different environments. For instance, production inherits most of our default settings like caching everything and E-mailing out error messages. However, in our environments.xml file we override those settings so dev doesn't cache anything and doesn't E-mail. Our default ColdBox config file has the following line for our ColdBox log locations:
[code]<!--The absolute or relative path to where you want to store your log files for this application-->
<Setting name="ColdboxLogsLocation"			value="D:\logs\" />[/code]
Our staging and production servers us that setting. However, in environments.xml we override that setting for our dev environment like so:
[code]<!-- Error Reporting -->
<Setting name="ColdboxLogsLocation"			value="E:\logs\" />[/code]
It seemed obvious that ColdBox was attempting to initialize the wrong log location for the dev environment. Glancing at our ColdFusion debugging proved that the environments.xml.cfm file was, in fact being ran so that ruled out a mapping issue. After stepping through the code a bit more we finally found the root of the issue. The cart was getting before the horse in the configLoader method of the LoaderService.cfc. Line 103 attempted to intialize the log location with the following code:
[code]//Initialize Logging if requested.
if ( controller.getSetting("EnableColdboxLogging") ){
AFTER that by a few lines of code (Line 107) is where we register our interceptors. You will recal that our environment settings are handled by an environmentControl interceptor which, by default, fires when configured.
[code]//Register The Interceptors
Essentially, we are trying to initialize the logging directory before we know where it is supposed to go. A quick glance at the 2.6.1 version of the LoaderService.cfc shows that the reinitialization of logs used to happen down in the registerAspects method which isn't called until the configLoader method is complete. To fix our dev server now running 2.6.2 we simply moved the initLogLocation() line down below the processState("afterConfigurationLoad") line. (Even though the environmentControl interceptor fires on configuration by default, it technically might not fire until the afterConfigurationLoad event fires. I'm can't promise that our fix is the right one. Usually people don't move code around for no good reason so there might be a purpose for having it run in the other order. As soon as Luis responds to the E-mail we sent him I will update you. So, to sum this up, you will only run into this if upgrading to ColdBox 2.6.2 AND using ColdBox debugging AND overriding specific logging locations in your environments.xml.cfm file.


Luis Majano

thanks!! This is an ovesight that was left but will be corrected soon enough and in 2.6.3 maintenance release

Site Updates

Entry Comments

Entries Search