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:
Once you have this shell, you will create a logBox
variable in the variables
scope that must be a structure with the following keys:
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:
To configure the root logger use the following keys:
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:
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.
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:
CFCConfig
: The object instance that has the logbox configuration data
CFCConfigPath
: The instantiation path of the object that has the logbox configuration data
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.
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)
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])
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
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 *)
The methods shown below are used to add categories to specific severity levels only. Each method can receive 1 to * category arguments.
public void debug()
public void info()
public void warn()
public void error()
public void fatal()
public void off()
No matter what configuration you decide to use, you will always have to instantiate LogBox with a LogBoxConfig
object: logbox.system.logging.config.LogBoxConfig
. However you have the option of either talking directly to this CFC or creating a more portable configuration. This portable configuration we denote as a simple data CFC that contains the LogBox configuration data using what we call our LogBox DSL (Domain Specific Language).
The cool thing about this LogBox DSL is that it is exactly the same whether you are using LogBox in ColdBox applications or in any other framework or non-framework ColdFusion application. So you can configure LogBox by:
Creating a portable data CFC using the LogBox DSL or
Creating the LogBoxConfig
object and interacting with its methods
Name
Description
name
A unique name for the category to register. Only unique names can be registered per instance.
levelMin
The default min log level for this category. (OPTIONAL. Defaults to 0 [FATAL].)
levelMax
The max default log level for this category. (OPTIONAL. Defaults to 4 [DEBUG].)
appenders
A list of appender names to configure this category with else it will use all the appenders in the root logger. You can also use * to add all registered apenders. (OPTIONAL)
Name | Description |
name | A unique name for the appender to register. Only unique names can be registered per instance. |
class | The appender's class to register. We will create, init it and register it for you. |
properties | The structure of properties to configure this appender with. (OPTIONAL) |
layout | The layout class path to use in this appender for custom message rendering. (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].) |
Name | Description |
levelMin | The default minimum log level for the root logger. (OPTIONAL. Defaults to 0 [FATAL].) |
levelMax | The default maximum log level for the root logger. (OPTIONAL. Defaults to 4 [DEBUG].) |
appenders | A list of appenders to configure the root logger with. Use |