Send email on any server (backend) error, handles or unhandled


I was just wondering if there is some way to configure server to send any backend exception to a particular support or dev email address.

This will help in pro actively find and fix issues.



It is possible with logback SMTPAppender: Chapter 4: Appenders

Sample configuration from docs:

  <appender name="EMAIL" class="">
    <to>ANOTHER_EMAIL_DESTINATION</to> <!-- additional destinations are possible -->
    <subject>TESTING: %logger{20} - %m</subject>
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%date %-5level %logger{35} - %message%n</pattern>

  <root level="DEBUG">
    <appender-ref ref="EMAIL" />

You can configure it in logback.xml file in your tomcat or WAR file.

1 Like

This works like a charm.