Are you emailing yourself your log errors? You should be.

September 26, 2008

Time and time again, users complain about an application crashing on them or otherwise not working. They don't provide you any info and it's hard to repeat. You check out the log, but there's thousands (or millions) of entries and you have no clue where their error occured. Worse, if you are deploying a RIA, the log may be on their computer and not available.

On my last project we experienced this scenario so much that we instituted two things

  • All messages logged with Level.ERROR in log4j would be emailed to us
  • All exceptions caught on the client would be packaged and sent back to the server and logged at Level.ERROR level (thus emailing them to us
After the initial deluge of emails, we found a lot of bugs. I mean a lot of bugs. The annoying, intermittent kind that are hard to reproduce. Further, by judicious use of logging, we discovered a lot of mis-configured environments and other problems without having to get users to mail us their logs.

At Gliffy, they are doing the same thing. Right now, we're testing a bunch of new features and the stage instance just sent me a bunch of emails, all indicating configuration problems, which is the exact kind of thing that can be hard to track down.

Setting it up using log4j is dead simple:
log4j.appender.mail.Subject=Errors from @SMTP_DESC@
log4j.appender.mail.layout.ConversionPattern=%d %p%n%t%n%c:%M:%L%n---%n%m%n---%n%n 
In my previous job I even created a customized layout to format the emails in such a way that our code was highlighted and GMail didn't compress things into threads.

If you aren't doing this, you should be. Now.