bhartsfield
12/01/2022, 5:04 PMbhartsfield
12/01/2022, 5:05 PM...
dbLogger : {
class : "DBAppender",
properties : {
dsn : "localdev_testdb_001",
schema : "Audit",
table : "DiagnosticLogs",
autocreate : false,
async : true,
rotationFrequency : 60,
rotationDays : 90,
columnMap : {
"id" : "Guid",
"severity" : "LogLevel",
"category" : "LogSource",
"logdate" : "DateCreated",
"appendername" : "Logger",
"extrainfo" : "Details"
}
}
},
...
And the root logger is configured as such in /app/config/ColdBox.cfc
root : {
levelMin : 0,
levelMax : 3,
appenders : "coldboxTracer,dbLogger,fileLogger"
},
Now, if I inject logbox using
property name="log" inject="logbox:logger:{this}" and I dump that property)
and then dump( log ), the min log level is 0 and the max is 4. Which means all of my if( log.canDebug() ) log.debug( ... ) calls always run.
Any ideas where things might be going wrong?wil-shiftinsert
12/01/2022, 5:13 PMbhartsfield
12/01/2022, 5:14 PMbhartsfield
12/01/2022, 5:16 PMlogBox = {
// Define Appenders
appenders : {
coldboxTracer : { class : "coldbox.system.logging.appenders.ConsoleAppender" },
dbLogger : {
class : "DBAppender",
properties : {
dsn : "localdev_testdb_001",
schema : "Audit",
table : "DiagnosticLogs",
autocreate : false,
async : true,
rotationFrequency : 60,
rotationDays : 90,
columnMap : {
"id" : "Guid",
"severity" : "LogLevel",
"category" : "LogSource",
"logdate" : "DateCreated",
"appendername" : "Logger",
"extrainfo" : "Details"
}
}
},
fileLogger : {
class : "RollingFileAppender",
properties : {
filePath : getSystemSetting( "LOG_FILE_ROOT", "../logs" ),
fileName : "logbox",
autoExpand : true,
fileMaxSize : 2000,
fileMaxArchives : 5
}
},
coldBoxInfoLogger : {
class : "RollingFileAppender",
properties : {
filePath : getSystemSetting( "LOG_FILE_ROOT", "../logs" ),
fileName : "logbox_coldbox",
autoExpand : true,
fileMaxSize : 2000,
fileMaxArchives : 5
}
}
},
// Root Logger - If no category matches the log, it falls back on the catch-all root configuration and routes it to all configured appenders
root : {
levelMin : 0,
levelMax : 3,
appenders : "coldboxTracer,dbLogger,fileLogger"
},
categories : {
"coldbox.system" : {
appenders : "coldBoxInfoLogger",
levelMin : 3,
levelMax : 3
}
}
};
bhartsfield
12/01/2022, 5:17 PMbhartsfield
12/01/2022, 5:18 PMwil-shiftinsert
12/01/2022, 5:19 PMwil-shiftinsert
12/01/2022, 5:20 PM// silence model.class, model2.class2
off = ["model.class", "model2.class2"],
// make myNewModule and qb very chatty
debug = ["myNewModule","qb"]
bhartsfield
12/01/2022, 5:21 PMwil-shiftinsert
12/01/2022, 5:24 PMwil-shiftinsert
12/01/2022, 5:24 PMbhartsfield
12/01/2022, 5:24 PMbhartsfield
12/01/2022, 7:25 PMproperty name="wirebox" inject="wirebox";
property name="log" inject="logbox:logger:{this}";
dump( log ) always appears to be a new logger instance with none of my settings (including no appenders... even though the dbAppender clearing logs to the db fine) with a default levelMin of 0 and levelMax 4
dump( wirebox.getLog() ) however is getting its levelMin and levelMax values from the coldbox.system category in my config (which are both set to 3). I can changes those values and confirm they update.
appenders is an empty struct in both dumpswil-shiftinsert
12/01/2022, 7:45 PMbhartsfield
12/01/2022, 8:01 PMbhartsfield
12/01/2022, 8:17 PMbhartsfield
12/01/2022, 8:18 PMbhartsfield
12/01/2022, 8:18 PMwil-shiftinsert
12/01/2022, 8:18 PMbhartsfield
12/01/2022, 8:23 PMbhartsfield
12/01/2022, 8:25 PMbhartsfield
12/01/2022, 9:45 PMbhartsfield
12/01/2022, 10:15 PMwil-shiftinsert
12/02/2022, 11:54 AMcoldbox.system.subsystem
) matches, it will take the configured loglevels or if not specified 0 (fatal) to 4 (debug). if your category does not match the rootlogger will be used with configured loglevels or default levels (0-4).
Once you try to log something to your logger it will look for the severity level first, and only if it matches (canLog) it will find out which appenders have the correct severity level.
So it is a two step filter. Filter 1 is your logger, step 2 is the appender. So if you try to log a debug message and both the root logger AND your coldbox.system
logger have a max level of INFO, it shouldn’t log at all, even if your appenders have a debug level. If the first filter (the logger itself) already stops your DEBUG message, the appender config should be irrelevant. So I am assuming somewhere in the proces your logger levels are not set at all or set to incorrect values which could make the maxLevel fallback to DEBUG.
On the other hand: if you configure ALL appenders to have a maxLevel of INFO you will not see the DEBUG messages at all, which is what you want.
I hope I am clear 🤔 in my explanation. You can see the mechanism in coldbox.system,logging.Logger.cfc
in the LogMessage()
method. Both the Logger and the Appender have canLog
methods, which should obey the configured levels.bhartsfield
12/02/2022, 12:20 PMwil-shiftinsert
12/02/2022, 12:23 PMwil-shiftinsert
12/02/2022, 12:25 PMbhartsfield
12/02/2022, 12:26 PMwil-shiftinsert
12/02/2022, 12:26 PMbhartsfield
12/02/2022, 12:28 PMbhartsfield
12/02/2022, 12:30 PM