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

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023