Blog

LogBox Beta 2 Released

Luis Majano July 16, 2009

Spread the word

Luis Majano

July 16, 2009

Spread the word


Share your thoughts

Another happy LogBox day.  Today we are releasing a quick beta update to LogBox.  This update includes a fix thanks to Mark Mandel and one of my favorite features: Category Inheritance. First of all, LogBox is an Enterprise Logging Library that is part of the up and coming ColdBox 3.0.0 Platform Suite.  It is completely standalone from ColdBox MVC and can be used in any project you like.  The full documentation can be found here: http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbLogBox and you can download it from here: http://www.coldbox.org/index.cfm/download A little background: The logger component is a named entity that you will use to log or trace messages to in LogBox. The logger will then be responsible for deciding if the severity level of the message is adequate for redirecting to a destination via its attached appenders.  Appenders are destinations for messages, these can be from files, to console to even Twitter.  So if these loggers can send messages then the logger will mediate the message(s) to the configured appender(s) for delivery. The named entity is called a category, but it is essentially just an identifier name.  This name follows a dot-notation convention that matches the location of the component or template you are trying to log.  Let's say I am logging from an object called: com.luismajano.util.FileUtils, then my category will be com.luismajano.util.FileUtils. Well, since we have this convention that category names should be in dot-notation form according to component or functionality, we can use a category inheritance for logging levels and appenders. Ok, that doesn't really tell you much, I know, but the following example will clarify this.

The overall premise is that when you request a logger with a category name, LogBox will search for its configuration (logging levels and appenders), if it does not find it it will try to locate its closest ancestor for logging levels and appenders, if it cannot find one, the it will rely on the root logger information (A default logger we ALWAYS define). Let's say we define some categories like this:

// Configured Appenders: FileAppender, ConsoleAppender, TwitterAppender config.category(name="coldbox.system",levelMin=config.logLevels.DEBUG,appenders="console"); config.error("coldbox.system.plugins"); Then let's say we request the following logger objects: logger = logBox.getLogger("coldbox.system.plugins.BeanFactory"); logger.info("hello info"); logger.error("wow and error occurred"); logger = logBox.getLogger("coldbox.system.interceptors.SES"); logger.info("hello info"); logger.debug("a cool debug message"); Below is a chart representation of the category inheritance in our example:
category configured levels assigned levels appenders
root FATAL-TRACE FATAL-TRACE console,file,twitter
coldbox.system DEBUG-TRACE DEBUG-TRACE console
coldbox.system.plugins ERROR ERROR *
coldbox.system.interceptors.SES NONE DEBUG-TRACE from coldbox.system console from coldbox.system
coldbox.system.plugins.BeanFactory NONE ERROR from coldbox.system.plugins *

Since we requested the category: coldbox.system.plugins.BeanFactory, LogBox tries to locate it, but it has not been defined, so it takes off the last item in the category name. Now it will search for a category of: coldbox.system.plugins via pseudo-inheritance. However, now coldbox.system.plugins HAS been found and it has been configured to only listen to error messages. Therefore, the coldbox.system.plugins.BeanFactory logger can ONLY log error messages according to its inherited category. So the info() message will be ignored.

The second logger is called coldbox.system.interceptors.SES, LogBox tries to match a category but fails, so it now searches for a logger called coldbox.system.interceptors. It still cannot find it so it continues up the package chain and finds the coldbox.system logger which has been set with a minimum of DEBUG level and ONLY the console appender. So the only message that get's logged is the logger.debug() message and into the console appender.

I hope these examples give you insight into category inheritance and the power it can give you because you can easily turn on/off logging for entire packages with one single category definition. However, this is great only if you follow the dot notation conventions. Below is a sample generic chart sample:

category configured levels assigned levels
root FATAL-TRACE FATAL-TRACE
x NONE FATAL-TRACE from root
x.y INFO INFO
x.y.z NONE INFO from x.y


Add Your Comment

Recent Entries

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024
Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024