title: Using log4j to send email reports via the SMTPAppender
body: <p>I'm trying to use log4j to send emailable reports that contain the logging statements from a background process.  I want one email sent for each process run, not one email for each logging statement.  I've looked at the <code>SMTPAppender</code>, but don't see a way to manually send the report when the process completes.  I believe the <code>TriggeringEventEvaluator</code> may be the key, but one issue I'm running into is how to get a handle to the <code>TriggeringEventEvaluator</code> instance.  I'm stuck using log4j 1.2.14 and the <code>SMTPAppender.getEvaluator()</code> method was introduced in 1.2.15.  Any thoughts?  Am I even on the right track?  Does the <code>SMTPAppender.close()</code> method come into play here?</p>
  
  <p>I want to be able to do this:</p>
  
  <pre><code>log.info(message1);
  log.info(message2);
  log.info(message3);
  log.sendMail();
  </code></pre>
  
  <p>After thinking about this some more, I think I need to clarify what I'm hoping to accomplish.  I'm trying to capture the logging from running a quartz job and send the resulting log as an email.  The quartz job makes a bunch of service method calls into various services.  I want the to include any logging those service methods perform as well as the logging of the quartz jobs itself.  I was thinking I could do something like the following for capturing all the logging, but it isn't working.</p>
  
  <pre><code>// at the beginning of quartz job
  Logger logger = Logger.getRootLogger();
  StringWriter sw = new StringWriter();
  WriterAppender wa = new WriterAppender(new SimpleLayout(), sw);
  logger.addAppender(wa);
  
  // at the end of the quartz job 
  String report = sw.toString();
  </code></pre>