ColdBox allows for a programmatic approach via the ColdBox.cfc
configuration object. So let's look at how the ColdBox loader looks at your configuration:
Is there a logBox
variable defined in the configuration?
False:
Does a LogBox.cfc
exist in the application's config
folder?
True: Use that CFC by convention to configure LogBox
False: Continue to next point
Configure LogBox with default framework settings (coldbox.system.web.config.LogBox
)
True:
Have you defined a configFile
key?
True: Then use that value to pass into the configuration object so it can load LogBox using that configuration file (CFC)
False: The configuration data is going to be defined inline here so process it
So the configuration DSL is exactly the same as you have seen in before with the only distinction that you can add a configFile
key that can point to an external configuration file (CFC).
Every ColdBox application can use LogBox by default since the main engine already uses it. By default ANY ColdBox application will be configured with a LogBox instance with the following appenders:
Also, the app will log on ANY severity by default up to INFO
for the root logger and the ColdBox package. You can customize this default behavior by creating or modifying the LogBox
element in your ColdBox configuration file and follow the same configuration approach as any normal LogBox configuration file.
The LogBox instance is stored in the ColdBox main controller object (coldbox.system.web.Controller
) and you can retrieve it like so from any handler, or interceptor.
WireBox DI and Injection can talk to LogBox. This way you can easily use our dependency injection DSL for LogBox related objects:
Type | Description |
---|---|
Below you can see the most common usage of this dependency DSL:
logbox
Get a reference to the application's LogBox instance
logbox:root
Get a reference to the root logger
logbox:logger:category
Get a reference to a named logger by its category name
logbox:logger:{this}
Get a reference to a named logger according to the current class path of the injected target
The ColdBox Proxy (coldbox.system.remote.ColdboxProxy
) object also has three utility methods you can use to talk to LogBox from any remote proxy you create:
getLogBox()
: Get a reference to the LogBox instance.
getRootLogger()
: Get a reference to the root logger.
getLogger(category:any)
: Get a named logger instance or reference.
Just by building a ColdBox application, you get several key benefits when dealing with LogBox.
First of all, the configuration, creation and instantiation is ALL done for you.
You can configure LogBox on a per-environment criteria as the ColdBox per-environment routines can use the LogBox configuration elements in its definitions.
Every handler and interceptor already has a reference to the LogBox instance as a property called: logBox
. So you have immediate access to it.
Every handler and interceptor already has a configured logger instance as a property called: log
. So you have immediate access to it.
You can configure the logging of ColdBox on a per package level.
You get the power of ColdBox MVC.