1 Reply Latest reply on May 18, 2012 5:31 AM by olegboa

    log4j-SMTPappender not working in jboss-logging (AS6 final)

      Hi!

       

      I'm using JBOSS 6.1.0.Final "Neo". I want to receive error messages by mail. I've created smtp appender in jboss-logging.xml:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!--                                                                       -->
      <!--  Logging System Configuration                                         -->
      <!--                                                                       -->
      <!-- ===================================================================== -->
      
      <logging xmlns="urn:jboss:logging:6.0" xmlns:b="urn:jboss:bean-deployer:2.0">
      
         <!-- ================================= -->
         <!-- Preserve messages in a local file -->
         <!-- ================================= -->
      
         <!-- A time/date based rolling handler -->
      
         <periodic-rotating-file-handler
               file-name="${jboss.server.log.dir}/server.log"
               name="FILE"
               autoflush="true"
               append="true"
               suffix=".yyyy-MM-dd">  <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->
      
            <error-manager>
               <only-once/>
            </error-manager>
      
            <formatter>
               <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->
               <!-- Uncomment this to get the class name in the log as well as the category
               <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>
               -->
               <!-- Uncomment this to log without the class name in the log -->
               <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
            </formatter>
         </periodic-rotating-file-handler>
         <console-handler name="CONSOLE" autoflush="true" target="System.out">
            <error-manager>
               <only-once/>
            </error-manager>
      
            <level name="INFO"/>
      
            <formatter>
               <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>
            </formatter>
         </console-handler>
        
        
         <log4j-appender name="SMTP_MY" class="org.apache.log4j.net.SMTPAppender">
            <error-manager>
               <only-once/>
            </error-manager>
      
            <level name="FATAL"/>
      
            <properties>
       <property name="to">dev@my.domain.com</property>
               <property name="from">IG@my.domain.com</property>
               <property name="subject">JBoss Server FATAL</property>
               <property name="SMTPHost">mail.my.domain.com</property>
               <property name="bufferSize">512</property>
            </properties>
      
            <formatter>
               <pattern-formatter pattern="%d %-5p [%c] (%t) %m%n"/>
            </formatter>
         </log4j-appender>
        
        
         <logger category="org.apache">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the jacorb category to WARN as its INFO is verbose -->
         <logger category="jacorb">
            <level name="WARN"/>
         </logger>
      
         <!-- Limit JSF to INFO as its FINE is verbose -->
         <logger category="javax.enterprise.resource.webcontainer.jsf">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
         <logger category="org.jgroups">
            <level name="WARN"/>
         </logger>
      
         <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
         <logger category="org.quartz">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the com.sun category to INFO as its FINE is verbose -->
         <logger category="com.sun">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the sun category to INFO as its FINE is verbose -->
         <logger category="sun">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the javax.xml.bind category to INFO as its FINE is verbose -->
         <logger category="javax.xml.bind">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the springframework category to WARN-->
         <logger category="org.springframework">
            <level name="WARN"/>
         </logger>
      
         <logger category="com.arjuna.ats">
           <level name="INFO" />
         </logger>
      
         <!-- Limit the JSR77 categories -->
         <logger category="org.jboss.management">
            <level name="INFO"/>
         </logger>
      
         <!-- Limit the verbose facelets compiler -->
         <!-- Also suppress error with legacy facelets (JBAS-7600) -->
         <logger category="facelets.compiler">
            <level name="WARN"/>
            <filter>
               <not>
                  <match pattern="Error\sLoading\sLibrary.*jsf-libs/jsf-impl"/>
               </not>
            </filter>
         </logger>
        
      
         <logger category="org.jboss.serial">
            <level name="INFO"/>
         </logger>
      
          <!-- Reduce org.mc4j stuff in the logs -->
         <logger category="org.mc4j">
            <level name="WARN"/>
         </logger>
         <!-- This is a temporary workaround for https://jira.jboss.org/jira/browse/EMBJOPR-280 and
              should be removed once that bug if fixed in the bundled admin-console war. -->
         <logger category="org.rhq.plugins.jbossas5.ApplicationServerComponent">
            <level name="FATAL"/>
         </logger>
      
         <!-- ======================= -->
         <!-- Setup the Root category -->
         <!-- ======================= -->
      
         <root-logger>
            <!-- Set the root logger priority via a system property, with a default value. -->
            <level name="${jboss.server.log.threshold:INFO}"/>
            <handlers>
               <handler-ref name="CONSOLE"/>
               <handler-ref name="FILE"/>
               <handler-ref name="SMTP_MY"/>
       </handlers>
         </root-logger>
      
      </logging>
      
      
      

       

      In a console output I see presence FATAL messages, but I do not receive it by mail

       

      15:15:18,687 INFO  [AbstractServer] Starting: JBossAS [6.1.0.Final "Neo"]
      15:15:22,468 INFO  [ServerInfo] Java version: 1.6.0_31,Sun Microsystems Inc.
      15:15:22,468 INFO  [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
      15:15:22,484 INFO  [ServerInfo] Java VM: Java HotSpot(TM) Server VM 20.6-b01,Sun Microsystems Inc.
      15:15:22,484 INFO  [ServerInfo] OS-System: Windows XP 5.1,x86
      
      ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      
      2012-05-17 15:18:35,531 FATAL [AIS OGD] (WorkerThread#0[192.168.135.130:3962])
      INSERT INTO IG.INQ_ANS (ID_INQ,ID_ANS,TYPEDTINQ,TYPEDTANS,IGSYSDATEUP,IGUSERUP,IGSYSDATE,IGUSER)VALUES('-3381ae86:11f1ca6ddb6:-7faf00000','-3381ae86:11f1ca6ddb6:-7fd100000','D_IN_____','D_AN_____',TO_TIMESTAMP('17.05.2012 15:18:29','dd.mm.yyyy hh24:mi:ss'),'IG',TO_DATE('17.05.2012','dd.mm.yyyy'),'IG')
      ORA-00001: unique constraint (IG.XPKINQ_ANS) violated
      IG
      INQ_ANS
      
      2012-05-17 15:18:35,546 ERROR [STDERR] (WorkerThread#0[192.168.135.130:3962]) log4j:ERROR Message object not configured.
      
      

       

      PS However JBoss 4.2.3.GA it's works perfectly!