3 Replies Latest reply on Jul 21, 2008 9:54 AM by alrubinger

    Stop hibernate to log errors in log4j error level

    cattivik100

      I'm using an email appender in log4j (org.apache.log4j.net.SMTPAppender) for logging exception to an email address.
      Basically I want to log only exceptions coming from log.error() calls in code.
      But jboss (hibernate) log some exceptions (org.hibernate.util.JDBCExceptionReporter) in error log level.
      So in log file I have some entry coming from hibernate even if I catch corresponding exceptions and manage them properly.
      Those cause unnecessary error mails to be notified.
      Is there a way to avoid hibernate to log errors in log4j error level?
      Many thanks
      philip

        • 1. Re: Stop hibernate to log errors in log4j error level
          jaikiran

          Change the logging level of the hibernate package to FATAL (if you don't need ERROR messages):

          <category name="org.hibernate">
           <priority value="FATAL" />
          
           </category>


          or the other way is to change the Threshold of the SMTPAppender to FATAL. But note that ERROR messages from non-hibernate packages too will be ignored in this case.

          <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
           <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
           <param name="Threshold" value="FATAL"/>
           <param name="To" value="admin@myhost.domain.com"/>
           <param name="From" value="nobody@myhost.domain.com"/>
           <param name="Subject" value="JBoss Sever Errors"/>
           <param name="SMTPHost" value="localhost"/>
           <param name="BufferSize" value="10"/>
           <layout class="org.apache.log4j.PatternLayout">
           <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
           </layout>
           </appender>


          • 2. Re: Stop hibernate to log errors in log4j error level
            cattivik100


            Damn... ouch...
            Yes you're right!
            I could thing to it myself.
            Many many thanks

            • 3. Re: Stop hibernate to log errors in log4j error level
              alrubinger

              As Jaikiran said, but I'd instead only filter down the offending category, not all of org.hibernate:

              <category name="org.hibernate.util.JDBCExceptionReporter">
               <priority value="FATAL" />
              </category>


              S,
              ALR