Best practice Qs for LogBox in ColdBox

Reading through the LogBox docs, it looks like you can configure
default behavior on the <Root> logger and then override it with
<Category> loggers but I can't see how to specify different
<Appender>s for different log levels on the <Root> logger.

I'd like to have all levels logged to one <Appender> but have FATAL
errors also go to an EmailAppender. Am I just missing something in the
docs or is this not possible?

I can get around this by defining categories matching the top-level
component paths in my application that only catch FATAL and have the
EmailAppender defined (although I'll need several such categories, to
cover different parts of my app) and then ensuring I use
logbox.getLogger(this) everywhere rather than the older plugin
approach.

Apart from that one apparent limitation, LogBox seems very powerful
and very sophisticated.

I think we'll be using a custom appender that extends the DB appender
but maps the extra info to more columns in the DB to make it easier to
do reporting and analytics against the events we'll be logging. Still
investigating that so any input would be welcome!

Hi Sean,

you hit the nail in the head!! I made a ticket for this a while back and it is scheduled for the next release. Basically, I also found out that it was sometimes necessary to have logging levels at the appender level. So the last line of defense is on the Appender, if you so desire.

So yes, this enhancement request is logged and coming :slight_smile:

then ensuring I use
logbox.getLogger(this) everywhere rather than the older plugin
approach

Sean, in 3.0.0 all plugins, handlers, layouts, views, and interceptors have several objects available to them in the variables scope.

  • controller : The main coldbox controller
  • logBox : A reference to LogBox
  • log : A pre-configured logger object using getLogger(this)
  • flas : A reference to the configured Flash Scope:

http://wiki.coldbox.org/wiki/WhatsNew:3.0.0.cfm#New_Object_Properties

Apart from that one apparent limitation, LogBox seems very powerful
and very sophisticated. I think we’ll be using a custom appender that extends the DB appender
but maps the extra info to more columns in the DB to make it easier to
do reporting and analytics against the events we’ll be logging. Still
investigating that so any input would be welcome!

Thanks Sean!! LogBox has really made my loggin in CF FUN AGAIN! Creating appenders left and right, using debug mode to trigger logging levels so I can see stuff in production while in debug mode, etc. It has really opened up LOTS AND LOTS of possibilites.

The cool thing is that not only does the appenders receive messages but also an extraInfo data argument which can be ANYTHING. Then each appender can determine how to treat that argument and log it accordingly. You can pass objects, structures or whatever here and then have each appender customize it as you see fit.

You can also create your own appender layouts, so basically, reuse the appender but just change the way the message gets logged, kinda like formatting YOUR way.

Anyways, as you can see, I also get giddy and excited about LogBox!! Please send me all your requests and make Logging FUN AGAIN!! (* Geek Alert *)

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

you hit the nail in the head!! I made a ticket for this a while back and it
is scheduled for the next release. Basically, I also found out that it was
sometimes necessary to have logging levels at the appender level. So the
last line of defense is on the Appender, if you so desire.
So yes, this enhancement request is logged and coming :slight_smile:

Cool. Doesn't help me today tho' :slight_smile: :slight_smile:

* log : A pre-configured logger object using getLogger(this)

Good to know that log is already pre-configured to that value. You
might want to make that clear in the docs. Right now (on the LogBox
page) it says:

"Every handler, interceptor and plugin already has a configured logger
instance as a property called: log. So you have immediate access to
it."

It doesn't say *how* it is configured!

It also says to use this to retrieve it:

    logBox = getController().getLogBox();

but logbox is already available as a variable.

It's also a little confusing when it shows the autowiring DSL because
that also implies you need to do something specific to get access to
the logger:

"Below you can see the most common usage of this dependency DSL:
..."

That should probably repeat the variables available in handlers,
plugins and interceptors and say that you can wire logging into a
service/model cfc using this mechanism.

Mostly, I'll be using it within services that are (fairly) independent
of ColdBox and rely on ColdSpring for DI so I'll use the
ColdBoxFactory to get LogBox and inject it via ColdSpring I expect.

Anyways, as you can see, I also get giddy and excited about LogBox!! Please
send me all your requests and make Logging FUN AGAIN!! (* Geek Alert *)

Er, yeah... logging... fun... not two words I'd normally expect to see
in the same sentence :slight_smile:

Thanks Sean!! The Docs are still in flux at the moment as I update them to 3.0.0 standards. So great pointers! I have written them down in my notes for when I review the docs.

And yes, use the coldbox factory so you can tap into ColdSpring for DI.

Er, yeah… logging… fun… not two words I’d normally expect to see in the same sentence :slight_smile:

Awww, come on, logging is awesome!!

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

I realized this won't work. As soon as I define a category for, say,
"org.corfield" that just handles FATAL, anything below that which uses
info() will just be ignored rather than inheriting the root logger
according to the docs:

"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."

I think I'm going to need to create a custom appender that takes
different actions for FATAL to other levels?