
Hey guys, I have a Jetty application that I configured with Logback. I am trying to set it up so any errors that occur during execution are emailed to me. I am a bit of a noobie, and so far I haven't had any luck with this. I can only get exceptions emailed to me if I explicitly set a try/catch block in my code everywhere and call logger.error(...). Is there an easy way to cause all exceptions to be logged and emailed to me via my SMTPAppender? Here is the config I have attempted to use so far: <configuration debug="true"> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <SMTPHost>smtp.gmail.com</SMTPHost> <SMTPPort>465</SMTPPort> <SSL>true</SSL> <Username>myemail</Username> <Password>my password</Password> <To> myemail</To> <From> myemail</From> <Subject>TESTING: %logger{20} - %m</Subject> <layout class="ch.qos.logback.classic.html.HTMLLayout"/> </appender> <root level="debug"> <appender-ref ref="EMAIL" /> </root> <logger name="exception" level="ERROR"> <appender-ref ref="EMAIL"></appender-ref> </logger> <logger name="org.mortbay" level="error"> <appender-ref name="EMAIL"> </appender-ref></logger> <logger name="developerworks.jetty6" level="error"> <appender-ref name="EMAIL"> </appender-ref></logger> <logger name="jupiter.filters" level="error"> <appender-ref name="EMAIL"> </appender-ref></logger> <logger name="jupiter.messaging" level="error"> <appender-ref name="EMAIL"> </appender-ref></logger> </configuration> Thanks, Brian

Brian Moschel skrev:
Hey guys,
I have a Jetty application that I configured with Logback. I am trying to set it up so any errors that occur during execution are emailed to me. I am a bit of a noobie, and so far I haven't had any luck with this. I can only get exceptions emailed to me if I explicitly set a try/catch block in my code everywhere and call logger.error(...). Is there an easy way to cause all exceptions to be logged and emailed to me via my SMTPAppender? Would an approach with a Error page configured in your web application which knows how to call logger.error be usable?
If so, you most likely (taken from memory) need to wrap your checked exceptions in a servlet exception so they can bubble up to the web application, which then invokes the error page. -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!"

Hello Brian, Could you give an example of code which works and code which does not? Brian Moschel wrote:
Hey guys,
I have a Jetty application that I configured with Logback. I am trying to set it up so any errors that occur during execution are emailed to me. I am a bit of a noobie, and so far I haven't had any luck with this. I can only get exceptions emailed to me if I explicitly set a try/catch block in my code everywhere and call logger.error(...). Is there an easy way to cause all exceptions to be logged and emailed to me via my SMTPAppender?
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch
participants (3)
-
Brian Moschel
-
Ceki Gulcu
-
Thorbjoern Ravn Andersen