Sean Carpenter

Gmail Logging With Log4j 1.2.16

Log4j includes an SMTP appender that can be used to send logging messages via email. As of log4j 1.2.16, this built-in appender has the ability to send messages via Gmail.

Here is an example log4j configuration that uses Gmail to send logged messages:

The SMTPUsername, SMTPPassword, Subject, To, and From properties should be replaced with values appropriate for your situation. One thing that tripped me up originally is that the SMTPPort should be set to 465, not 587 as I had originally done.