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

Ortus June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024