I would like to suggest a change to the ColdBox Logger Plugin. I may
not have thought this all through correctly so please let me know if I
am missing something.
Long story short, the issue is that it is impossible to use the
ColdBox Logger Plugin with a LogBox appender that expects complex data
for the extraInfo value. By default the logger plugin is what we have
injected into out model and handlers with the following DSL:
In the past, in my custom exception handler I would call
That method extracts out several pieces of the error object and
appends them into a string buffer.
Now, we are flexing the power of LogBox and implementing a custom DB
Appender which will log all out errors in a database. We wish for the
entire cfcatch struct be passed into out db appender in the logEvent
object so we can do whatever we want with it; however logErrorWithBean
is "helpfully" turning it into text for us before that point. My
first thought was to stop calling logErrorWithBean in the logger
plugin and call logEntry() or error() directly. However, both of
those methods only accept an extraInfo parameter that is a "string".
So, basically the logger plugin will never hand anything other than a
"string" extraInfo over to LogBox.
We have worked around it for now by directly wiring LogBox in with
"coldbox:logbox", asking it for a logger named after the appName
setting (since that's what the logger plugin did. Is that correct?)
and calling its error() method directly.
That works, but now we lose the bugReport E-mail that the logger
plugin used to take care of. Ok, no problem, we'll just add in an E-
mail appender as well to replace that. (I've actually been meaning to
ask you for a while why the bugReport functionality isn't replaced
entirely by an E-mail appender in LogBox)
So, all that being said-- I think it might have made sense for the
logger plugin to ONLY pass strings through as extraInfo back in the
old days prior to the days of LogBox, but I don't think it's fair that
the logger plugin in ColdBox assumes that any extraInfo in an error
message should be reduced to a string now considering the vast power
and options LogBox gives us. I would like to suggest that the
logErrorWithBean method in the logger plugin pass through the
extraInfo in whatever state it is passed in as. Then, the decision of
what to do with it should be left up to the appender in question. The
logEvent.getExtraInfoAsString() method that you already have in place
might be an excellent place to move that logic to.
Well, actually I think logErrorWithBean should be completely
deprecated, and the logger plugin's error() method should be called
everywhere (including the ExceptionService) and a separate E-mail
appender configured if you want the bug report, but you may not agree
with me to that level.