3 Replies Latest reply on Apr 6, 2006 6:04 PM by Jimmy Wilson

    Sending Mail on Errors with Log4j

    Khoya Raaz Newbie

      Hi,
      I'm using jboss4.0.3SP1 right now, I was wondering how to get my errors/exceptions mailed to my email. I tried configuring the conf/log4j.xml file with the following setting:

      <!-- EMail events to an administrator -->
       <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="Threshold" value="ERROR"/>
       <param name="To" value="name@something.com"/>
       <param name="From" value="name@something.com"/>
       <param name="Subject" value="JBoss Sever Errors"/>
       <param name="SMTPHost" value="Success"/>
       <param name="BufferSize" value="10"/>
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
       </layout>
       </appender>

      I then use a Logger (org.jboss.Logging.logger) to catch an exception like this in my code:

      private Logger m_oLog = Logger.getLogger("NameOfBean");
      and in the code itself:
      catch(EntityNotFoundException e)
       {
      m_oLog.error("Cound not find PurchaseId: " + strPurchaseId);
       }


      What else am I missing?
      Thanks!