I'm implementing logbox to handle my 'exceptionHandler' in CB Config.
I'm using as a reference this article:
http://www.anujgakhar.com/2011/12/01/using-coldbox-and-logbox-for-error-logging/.
Basically I want an email notification when an exception occurs and
the error to be logged to the database. The database logging is
working fine, but I'm getting two emails for the one exception with
subjects that look like this:
1) ERROR-emaillogger-Error Email from Enrollment
2) ERROR-dbLog-Error Email from Enrollment
My logbox settings in coldbox are:
logBox = {
// Define Appenders
appenders = {
coldboxFile = {
class="coldbox.system.logging.appenders.AsyncRollingFileAppender",
properties={
filePath="logs",
fileName=coldbox.appname,
autoExpand=true,
fileMaxSize=2000,
fileMaxArchives=2
}
},
dbLog = {
class="coldbox.system.logging.appenders.AsyncDBAppender",
properties = {
dsn = 'edi',
table = '_ERRORS',
autocreate = true
},
levelMax = "WARN",
levelMin = "FATAL"
},
emailLog = {
class="coldbox.system.logging.appenders.EmailAppender",
properties =
{
from = 'errors@enrollment.com',
to = 'brett@enrollment.com',
subject = 'Error Email from Enrollment'
},
levelMax = "WARN",
levelMin = "FATAL"
}
},
root = {levelMax="INFO", appenders="*"},
categories = {
"dblogger" = { levelMin="FATAL", levelMax= "WARN",
appenders="dbLog" },
"emaillogger" = { levelMin="FATAL", levelMax= "WARN",
appenders="emailLog" }
},
OFF = ["coldbox.system"]
};
And what is happening in my onException handler is this:
function onException(event){
var exceptionBean = Event.getValue("ExceptionBean");
var info = {};
info.event = rc.event;
info.appuser = rc.appuser;
info.app_properties = rc.app_properties;
info.exception = exceptionBean.getMemento();
dblogger.error("MESSAGE:#exceptionBean.getExceptionStruct().message#,
DETAIL:#exceptionBean.getExceptionStruct().detail#",info);
emaillogger.error("MESSAGE:#exceptionBean.getExceptionStruct().message#,
DETAIL:#exceptionBean.getExceptionStruct().detail#",info);
}
Thoughts on why I would be getting two emails, instead of just the
one?
Thanks in advance.
Brett