[ColdBox 4.3.0] Logbox No appenders

Hi,
I am trying the features in LogBox. I create a database for logbox to write logs to.

In the config: Coldbox.cfc, I have the following setting:

logBox = {
// Define Appenders
appenders = {
dbLog = {
class=“coldbox.system.logging.appenders.DBAppender”,
properties =
{
dsn = ‘test’,
table = ‘logs’,
autocreate = true
},
levelMax = “INFO”,
levelMin = “FATAL”
}
},
root = {levelMax=“INFO”, appenders=“*”},
categories = {
“dblogger” = { levelMin=“FATAL”, levelMax= “INFO”, appenders=“dbLog” }
},
OFF = [“coldbox.system”]
};

And then I create an API as followed:

any function index( event, rc, prc ){
log.info(“hi there”);
writedump(“#log.hasAppenders() #”);
abort;
prc.response.setData( “Welcome to my ColdBox RESTFul Service” );
}

I check the database, the logs table is created successfully and the “hi there” info log is created as well.
However, the #log.hasAppenders() # shows false result. Also when I dump the appenders struct, it shows nothing.
I wonder if there is anything wrong I did about the setting of LogBox. appreciate any help. Thanks a lot!

That’s because your logger technically doesn’t have any appenders-- but it inherits from the root logger, which does! Run this:

log.getRootLogger().hasAppenders()

If you’re just using the “log” variable that is made automatically available in your handlers, then you’re not actually using the “dblogger” category that you created. ColdBox will have created a named/category logger called “handlers.yourHandlerName” and all loggers inherit from the root logger, and your root logger has “*” for appenders so that means the root logger is using the “dbLog” appender.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com