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

BoxLang 1.0.0 Beta 7 Launched

BoxLang 1.0.0 Beta 7 Launched

We are pleased to announce the release of BoxLang 1.0.0-Beta 7! This latest beta version includes improvements and essential bug fixes, but more importantly it certifies the execution of ColdBox HMVC and TestBox.

What is BoxLang?

BoxLang is a modern dynamic JVM language that can be deployed on multiple runtimes: operating system (Windows/Mac/*nix/Embedded), web server, lambda, iOS, android, web assembly, and more. BoxLang combines many features from different progr

Luis Majano
Luis Majano
July 26, 2024
New BoxLang Feature: Java Method References and Higher-Order Functions

New BoxLang Feature: Java Method References and Higher-Order Functions

We’ve added more goodies to our BoxLang Java interop: method references and higher-order functions. CFML has never let you do these things, making Java Interop feel like a second-class citizen. But with BoxLang, we’re elevating Java integration to a new level.

Maria Jose Herrera
Maria Jose Herrera
July 26, 2024
Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Are you a CFML developer looking to take your skills to the next level? Look no further than the ColdBox from Zero to Hero Virtual Live Training! This intensive two-day course will equip you with the knowledge and expertise to build robust and scalable applications using ColdBox 7, the latest version of the most popular CFML MVC framework.

What You'll Learn:

  • Master the Fun...

Cristobal Escobar
Cristobal Escobar
July 24, 2024