Search code examples
javatomcattomcat7monitoringcatalina.out

Email Me Every Time Catalina.out Receives an Exception


Struggling with finding a solution to the pain of having to constantly access my server, load the catalina.out file, and wade through the mess to find exceptions. What are developers using to constantly monitor the tomcat catalina.out file and send an email when an exception is found? I'd also be ok with some guidelines towards writing my own shell script to accomplish this. If shell scripting would be powerful enough for this type of thing.

My server is debian/ubuntu. I'm using Tomcat 7.

Note: I came across logwatch, but on initial review it doesn't seem to support tomcat without customizing, and it doesn't appear to be able to sniff out exceptions in the catalina.out file, and it doesn't appear to be a utility to monitors in real time. I'd rather not wait until the end of the day to learn about catastrophic exceptions that may be occuring.

Additional Note: I do plan on implementing something like log4j in the future, but at the moment I am looking for a quicker alternative. Something that doesn't require me updating all my exception handling code.


Solution

  • If you are using log4j you can just use the SMTP appender for error level ERROR. See the documentation for more information. I have used this with Tomcat in the past and it worked great.

    Also, this answer has a full example of using the SMTP appender to send emails.