Implementing Logbox

Hi all,

I am just finishing up an application, and now I am implementing
logbox.

I have configured three appenders for Logbox, ColdboxTrace, Async file
and Emailappender.

In the root property I have set up only the first two as appenders.
The mail appender does not fire on a standard error.

So far, so good. Now I have set up an onException in production mode,
in which I want to Email the error and then redirect to the friendly
error page. In development, I just show the error on the screen.

I have set up the two onExceptions using the Environment Interceptor.
But I can't figure out how I call the Emailappender in Logbox to email
the Exception bean.

How do i accomplish this?

Hope you can help,

Kind regards.

Erik-Jan

Ok,

First of all, you will have to declare a Category that will be assigned the Email Appender.

Example:

category(class=“myinterceptors.ExceptionHandler”,appenders=“EmailAppender”);

Also, choose a levelMin and levelMax for the category. What this does, is that when you use a logger in the interceptors of class type: myinterceptors.ExceptionHandler, then it will redirect all messages to the email appender.

All interceptors in 3.0.0 have a “log” object already in the variables scope. So in your interceptor you can do:

log.error(“message here”, extrainfo);

That will send the message and extra info via email to you.

To check the class path of your interceptor you can also do this:

But that is about it. Categories are granular controls of logging of which you can choose to what destinations to log to and what levels to allow.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Hi Luis,

Thanks for your reply.

I ended up taking a different approach, by settings the root.appenders for the development environment in the Environment interceptor.

I added this line to my development config:

And now only the production server mails the errors, development just shows them on the screen!

Works like a charm!

Kind regards,

Erik-Jan