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 23 Launched

BoxLang 1.0.0 Beta 23 Launched

The latest release of BoxLang, Beta 23, marks a significant step forward in our journey to create the ultimate dynamic language for the JVM. Packed with powerful new features, important bug fixes, and thoughtful optimizations, this update is designed to make your development experience smoother, faster, and more reliable, especially after now starting to take 100s of comments and bug reports from our community.

Luis Majano
Luis Majano
November 23, 2024
TestBox Latest Updates and News!

TestBox Latest Updates and News!

We’re thrilled to have launched the new TestBox website and TestBox 6.0! If you haven’t had a chance to explore yet, visit TestBox to discover updated documentation, powerful resources, and features that make testing more efficient than ever.

Maria Jose Herrera
Maria Jose Herrera
November 21, 2024
Is Your ColdFusion Application Ready for the Future?

Is Your ColdFusion Application Ready for the Future?

In a rapidly evolving digital world, maintaining performance, security, and scalability for ColdFusion applications is more challenging than ever. Whether you're using Lucee or Adobe ColdFusion, legacy systems can become a bottleneck for growth, innovation, and user satisfaction. The need to future-proof your ColdFusion applications has never been more critical.

But where do you start?


The Hidden Costs of an Outdated ColdFusion Application

As you...

Cristobal Escobar
Cristobal Escobar
November 21, 2024