If you are using java.util.logging or log4j, take a look at my article
"Reporting Application Errors by Email"
http://www.onjava.com/pub/a//onjava/2004/09/29/smtp-logging.html The article explains how to use log4j's SMTPAppender and how to configure the SMTPHandler for java.util.logging