Configuring LogBox

LogBox comes pre-configured for operation with very basic logging. However, you can customize it to your fancy using different configuration strategies using the programmatic configuration object or the LogBox Config DSL.

When you are in a ColdBox application, you will have a logbox structure in your ColdBox.cfc already that you can use, or you can create a portable CFC as well and place it in config/LogBox.cfc

Configuration can be done in the following ways:

  1. No configuration: Uses the default configuration shown below

  2. Portable CFC: Creating a portable data CFC using the LogBox DSL in a configure() method

  3. LogBoxConfig: Creating the LogBoxConfig object and interacting with its methods programmatically

  4. LogBox DSL Struct: Passing a struct literal into LogBox, using the LogBox DSL.

LogBox DSL

1. Default Configuration

This is the default configuration when LogBox is created with no config:

component {

  /**
   *  Configure logBox
   */
  function configure(){
    logBox = {
	// Define Appenders
	appenders : { 
		console : { class : "ConsoleAppender" } 
	},
	
	// Root Logger
	root : { 
		levelmax : "INFO", 
		appenders : "*" 
	}
    };
  }

}

// Instantiate it
application.logbox = new logbox.system.logging.LogBox();

2. Portable CFC

You can create a CFC with a single configure method with the LogBox configuration in a variable called logbox using the LogBox DSL.

3. Programmatic LogBoxConfig

4. Struct Literal Config

Was this helpful?