LogBox : Enterprise Logging & Messaging
6.x
6.x
  • Introduction
  • Intro
    • Release History
      • What's New With 6.8.0
      • What's New With 6.7.0
      • What's New With 6.6.0
      • What's New With 6.5.0
      • What's New With 6.2.0
      • What's New With 6.1.0
      • What's New With 6.0.0
    • About This Book
      • Author
  • Getting Started
    • Features at a Glance
    • Installation
      • LogBox Refcard
    • Need For Logging
    • How Does LogBox Work?
      • LogBox
      • Appender
      • Logger
        • Logger Category Inheritance
        • Security Levels
        • Dynamic Appenders
      • Layout
  • Configuration
    • Configuring LogBox
      • LogBox DSL
      • Adding Appenders
      • Adding Categories to Specific Loggin Levels
      • Adding Categories Granularly
      • Configuring The Root Logger
  • Usage
    • Using LogBox
    • Using a Logger Object
      • Can Methods For Performance
      • $toString() and ExtraInfo Argument
    • Appender Properties
      • CFAppender
      • ConsoleAppender
      • DBAppender
      • EmailAppender
      • FileAppender
      • RollingFileAppender
      • ScopeAppender
      • SocketAppender
      • TraceAppender
    • LogBox in a ColdBox Application
      • Configuration Within ColdBox
      • Benefits of using LogBox in a ColdBox application
      • Where is LogBox stored in a ColdBox app?
      • LogBox from the ColdBox Proxy
      • The LogBox Injection DSL
  • Extending LogBox
    • Creating Custom Appenders
      • Helper Methods
      • Instance Members
      • Dealing With Custom Layouts
      • Registering Appenders at Runtime
    • Creating a Custom Layout
      • Instance Members
Powered by GitBook
On this page
  • Base Config
  • Appenders
  • Root Logger
  • Categories
  • Instantiation

Was this helpful?

Edit on Git
Export as PDF
  1. Configuration
  2. Configuring LogBox

LogBox DSL

In order to create a simple data CFC, just create a CFC with one required method on it called configure where you will define the logging configuration data:

**
* A LogBox configuration data object
*/
component{

    function configure(){
        logBox={

        };
    }
}

Base Config

Once you have this shell, you will create a logBox variable in the variables scope that must be a structure with the following keys:

Key

Description

appenders

A structure where you will define appenders

root

A structure where you will configure the root logger

categories

A structure where you can define granular categories (OPTIONAL)

DEBUG

An array that will hold all the category names to place under the DEBUG logging level (OPTIONAL)

INFO

An array that will hold all the category names to place under the INFO logging level (OPTIONAL)

WARN

An array that will hold all the category names to place under the WARN logging level (OPTIONAL)

ERROR

An array that will hold all the category names to place under the ERROR logging level (OPTIONAL)

FATAL

An array that will hold all the category names to place under the FATAL logging level (OPTIONAL)

OFF

An array that will hold all the category names to not log at all (OPTIONAL)

Appenders

To define an appender you must define a struct with a key value which is the internal name of the appender. Each appender name must be unique. You configure each appender with the following keys:

Key

Description

class

The class path of the appender

properties

The properties struct for the appender (OPTIONAL)

layout

The layout class path of the layout object to use (OPTIONAL)

levelMin

The numerical or English word of the minimal logging level (OPTIONAL, defaults to 0 [FATAL])

levelMax

The numerical or English word of the maximum logging level (OPTIONAL, defaults to 4 [DEBUG])

Root Logger

To configure the root logger use the following keys:

Key

Description

levelMin

The numerical or English word of the minimal logging level (OPTIONAL, defaults to 0 [FATAL])

levelMax

The numerical or English word of the maximum logging level (OPTIONAL, defaults to 4 [DEBUG])

appenders

A string list of the appenders to use for logging

Categories

To define categories you must define a struct with a key value which is the internal name of the category. Each category name must be unique. You configure each category with the following keys:

Key

Description

levelMin

The numerical or English word of the minimal logging level (OPTIONAL, defaults to 0 [FATAL])

levelMax

The numerical or English word of the maximum logging level (OPTIONAL, defaults to 4 [DEBUG])

appenders

A string list of the appenders to use for logging (OPTIONAL, defaults to *)

As you might notice the name of the keys on all the structures match 100% to the programmatic methods you can also use to configure logBox. So when in doubt, refer back to the argument names.

Example Configuration

logBox = {
    // Appenders
    appenders = {
        appenderName = {
            class="class.to.appender",
            layout="class.to.layout",
            levelMin=0,
            levelMax=4,
            properties={
                name  = value,
                prop2 = value 2
            }
    },
    // Root Logger
    root = { levelMin="FATAL", levelMax="DEBUG", appenders="*" },
    // Granualr Categories
    categories={
        "coldbox.system" = { levelMin="FATAL", levelMax="INFO", appenders="*" },
        "model.security" = { levelMax="DEBUG", appenders="console" }
    }
    // Implicit categories
    debug = [ "coldbox.system.interceptors"  ],
    info  = [ "model.class", "model2.class2" ],
    warn  = [ "model.class", "model2.class2" ],
    error = [ "model.class", "model2.class2" ],
    fatal = [ "model.class", "model2.class2" ],
    off   = [ "model.class", "model2.class2" ]
};

Instantiation

Once you have defined the configuration data in this object you can now use the same LogBox Config object to either instantiate it for you or you can pass a reference of it by using the init() method of the LogBoxConfig object:

init([CFCConfig,CFCConfigPath])
  • CFCConfig : The object instance that has the logbox configuration data

  • CFCConfigPath : The instantiation path of the object that has the logbox configuration data

// Using config path
config = createObject( "component", "logbox.system.logging.config.LogBoxConfig" )
    .init( CFCConfigPath="my.path.LogBoxConfig" );
logBox = createObject( "component", "logbox.system.logging.LogBox" ).init( config );

// Using config object
data = createObject( "component", "my.data.CFC" );
config = createObject( "component", "logbox.system.logging.config.LogBoxConfig" ).init( data );
logBox = createObject( "component", "logbox.system.logging.LogBox" ).init( config );

That's it! Using this DSL approach, your configurations are much more portable now and can even be shared in ANY framework, ColdBox or ColdFusion application. So now let's explore how to bypass this data CFC and use the LogBoxConfig object directly. It is important to understand these methods as they are called for you when you define your LogBox DSL data.

PreviousConfiguring LogBoxNextAdding Appenders

Was this helpful?