Excluding Logbox appenders from default Coldbox logging


I’m using Coldbox and I’ve decided to do some extra configuration in logbox to add more appenders and categories. I successfully was able to inject logbox into one of my handlers and send test messages programmatically to each one of my appenders. So that was pretty nice, however, I did run into another issue.

It turns out, even when I commented out the injection of logbox, I was logging a bunch of messages from the Coldbox framework to each one of my appenders, even when I specifically told my root logger to only log to files (If that is what the root logger is supposed to to, I’m not sure).

The following is my coldbox.cfc file.

The types of messages that were sent to my email and database (where I didn’t want them to go) looked like the following.

So my question is, how do I exclude/specify which appenders for my default Coldbox logs to be pushed to? It looks like it’s just sending my logs to all of them.

The “categories” part of your config at the bottom isn’t right. Well, it may be-- it’s hard to tell what you’re trying to do there. Normally “category” names are things like coldbox.system or models.services, or models.beans.Company. You’re creating custom categories with a single appender and named after that appender. Which is fine if you are injecting those custom categories like so:

property name='consoleLogger' inject='logbox:logger:consoleLogger';

and then using consoleLogger.info() to log messages that will only go to one appender.

But back to Coldbox-- you are correct that your root logger is configured to only use the console appender, but the info : ['coldbox.system'] bit is likely explicitly creating the coldbox.system category with all appenders. I would try removing your info/coldbox line and instead adding another explicit category like so:

categories : {
  'coldbox.system' : { levelMin : 'info', appenders: 'consoleLog' }

which is more less the same as what you have but from another angle, and it lets you set the min/max levels as well as the appenders in one go.

And on a related note-- I usually don’t leave things like DB logs and mail logs wide open to log all messages. I’ll generally have those only logging serious stuff like errors and fatal, which sort of inherently takes care of the debug/info noise from Coldbox. Now, if you’re actually wanting an E-mail/DB record for every info message from your models, that’s fine. But I just wanted to point that out.

Thanks for the reply!

This is what I’m trying to do with custom categories. I’m making a template for an application and really just want to have some single-use categories that work out of the box and make intuitive sense.

The fix you suggested works. I think I have to fine tune what severity levels of messages I want to be included in logs, but now all of the coldbox.system logs are automatically written to a file, and no longer bombarding my inbox!

Thanks man!

1 Like

Excellent, glad it’s working and what you’re doing with the custom categories is totally fine :+1: