4 Replies Latest reply on May 28, 2004 9:36 AM by aalmero

    [log4j] SMTPAppender and Threshold INFO

    Peter Goetz Newbie

      Hi there,

      I have some questions concerning the SMTPAppender. I wanted to test it and therefore put the Threshold to INFO. Unfortunately I got no messages. I tried several days with different configurations but nothing changed.
      Then I changed the jboss setup that I get some errors. And - I finally got emails with these messages.
      Now my question: What do I have to do to change the threshold of the SMTPAppender?
      Here ist the important part of my log4j.xml:

      <!-- 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="DEBUG"/>
       <param name="To" value="admin@127.0.0.1"/>
       <param name="From" value="admin@127.0.0.1"/>
       <param name="Subject" value="JBoss WARN message"/>
       <param name="SMTPHost" value="127.0.0.1"/>
       <param name="BufferSize" value="512"/>
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
       </layout>
      </appender>
      <!-- -->
      
      <root>
       <appender-ref ref="CONSOLE"/>
       <appender-ref ref="FILE"/>
       <appender-ref ref="SMTP"/>
      </root>
      

      Thank you very much in advance for your help!!

      Peter


        • 1. Re: [log4j] SMTPAppender and Threshold INFO
          Ulf Schroeter Novice

          I encountered the same problem :-) It is caused by the default Log4j trigger for the SMTP-Appender that only triggers EMail send in case of ERRORS....

          I have extended the JBoss-Branch3.2-CVS with some more general evaluators for INFO-, WARN- and ERROR-Level-triggering

          org.jboss.logging.appender.InfoLevelEventEvaluator
          org.jboss.logging.appender.WarnLevelEventEvaluator
          org.jboss.logging.appender.ErrorLevelEventEvaluator

          He's an example for triggering mail send operation for log messages with level WARN and higher. Hope it will solve your problem :-)

          <!-- An EMail appender -->
           <appender name="SMTP_System" class="org.apache.log4j.net.SMTPAppender">
          
           <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
          
           <param name="EvaluatorClass" value="org.jboss.logging.appender.WarnLevelEventEvaluator" />
           <param name="Threshold" value="WARN"/>
           <param name="To" value="your.receiver@yourcompany.com"/>
           <param name="From" value="jboss@yourcompany.com"/>
           <param name="Subject" value="Server-Log-Message [<host>:${jboss.server.name}]"/>
           <param name="SMTPHost" value="your.mailhost.com"/>
           <param name="BufferSize" value="10"/>
          
           <layout class="org.apache.log4j.PatternLayout">
           <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
           </layout>
          
           </appender>
          


          • 2. Re: [log4j] SMTPAppender and Threshold INFO
            Peter Goetz Newbie

            Hi Ulf,

            thank you very much for your help.
            Unfortunately I have no access to CVS outside of the company.
            Would it be possible for you to send me these three files via email?
            My address is: kingofbrain@web.de
            Thank you very much for your help!

            Peter

            • 3. Re: [log4j] SMTPAppender and Threshold INFO
              aalmero Newbie

              add

              <appender-ref ref="SMTP"/>


              remove
              <appender-ref ref="SMTP"/>

              this is working with my setup.

              • 4. Re: [log4j] SMTPAppender and Threshold INFO
                aalmero Newbie

                please disregard earlier post.

                add

                 <category name="com.your.package">
                 <appender-ref ref="SMTP"/>
                 </category>
                


                remove from your config
                <appender-ref ref="SMTP"/>


                works well with my setup