7 Replies Latest reply on Nov 25, 2010 5:11 AM by nortendo

    receive a notification by mail when jboss is started

    nortendo

      Hello guys,

       

      i would like to receive an notification by mailbox when the jboss is started. I find the mbean: jboss.system:type=Server; Started = true but i don't know how to to receive a mail when the jboss is started ...

       

      Thanks a lot for your help ...

        • 1. Re: receive a notification by mail when jboss is started
          wdfink

          A simple solution is to use the log4j.

          Use the Mail appender and add a category INFO for jboss Server class.

          Set a filter for this message:

          [Server] JBoss ...... Started in ......

           

          Examples for Category, Appender and Filter you will find in the jboss-log4j.xml or in the Apache log4j manual.

          • 2. Re: receive a notification by mail when jboss is started
            nortendo

            Nice idea Wolf, i will investigate. Thanks a lot for your response

            • 3. Re: receive a notification by mail when jboss is started
              nortendo

              Sorry could you say if my syntax is correct ?

               

              <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
                    <errorHandler Class="org.jboss.logging.util.OnlyOnceErrorHandler">
                    <param name="Threshold" value="STARTED" />
                    <param name="To" value="xxxx@xxxxx" />
                    <param name="From" value="localhost" />
                    <param name="Subject" value="JBoss Started" />
                    <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> 
                
                 <category name="org.jboss.system.server.Server">
                          <priority value="INFO" />
                          <appender-ref ref="SMTP" />    
                 </category>   

               

              Thanks a lot for your help & your information. Have nice day & have nice week-end for everybody

              • 4. Re: receive a notification by mail when jboss is started
                wdfink

                Syntax is correct, but the element Threshold means 'FATAL....TRACE', you must set INFO!

                 

                Add the following:

                <filter class="org.apache.log4j.varia.StringMatchFilter">
                                  <param name="StringToMatch" value="Here is DEBUG" />
                                  <param name="AcceptOnMatch" value="true" />
                          </filter>

                <filter class="org.apache.log4j.varia.StringMatchFilter">

                                  <param name="StringToMatch" value="Started in" /> <!-- or better match -->

                                  <param name="AcceptOnMatch" value="true" />

                </filter>

                 

                Maybe you must add a DenyAll see documentation for log4j http://logging.apache.org/log4j/1.2/manual.html

                • 5. Re: receive a notification by mail when jboss is started
                  nortendo

                  This is the result of the file log4j.

                   

                  I have a big problem when the jboss is started, the file boot.log is created but the file server.log is not created.

                  The jboss works perfectly

                   

                  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

                   

                     <!-- ================================= -->

                     <!-- Preserve messages in a local file -->

                     <!-- ================================= -->

                   

                     <!-- A size based file rolling appender -->

                     <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">

                       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>

                       <param name="File" value="${jboss.server.log.dir}/server.log"/>

                       <param name="Append" value="false"/>

                       <param name="MaxFileSize" value="5000000KB"/>

                       <param name="MaxBackupIndex" value="1"/>

                   

                       <layout class="org.apache.log4j.PatternLayout">

                         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

                       </layout>       

                     </appender>

                   

                     <!-- ============================== -->

                     <!-- Append messages to the console -->

                     <!-- ============================== -->

                   

                     <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

                        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>

                        <param name="Target" value="System.out"/>

                        <param name="Threshold" value="INFO"/>

                   

                        <layout class="org.apache.log4j.PatternLayout">

                          <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>

                        </layout>

                     </appender>

                   

                     <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">

                        <errorHandler Class="org.jboss.logging.util.OnlyOnceErrorHandler">

                        <param name="Threshold" value="INFO" />

                        <param name="To" value="nortendo@gmail.com" />

                        <param name="From" value="localhost" />

                        <param name="Subject" value="Starting JBOSS" />

                        <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>

                        <filter class="org.apache.log4j.varia.StringMatchFilter">

                            <param name="StringToMatch" value="Started in" />

                            <param name="AcceptOnMatch" value="true" />

                        </filter>

                     </appender> 

                   

                     <!-- ================ -->

                     <!-- Limit categories -->

                     <!-- ================ -->

                   

                     <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->

                     <category name="org.apache">

                        <priority value="INFO"/>

                     </category>

                   

                     <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->

                     <category name="org.jboss.serial">

                        <priority value="INFO"/>

                     </category>

                   

                     <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->

                     <category name="org.jgroups">

                        <priority value="WARN"/>

                     </category>

                   

                     <!-- Limit the jacorb category to WARN as its INFO is verbose -->

                     <category name="jacorb">

                        <priority value="WARN"/>

                     </category>

                   

                     <category name="org.jboss.system.server.Server">

                              <priority value="INFO" />

                              <appender-ref ref="SMTP" />    

                     </category>     

                   

                     <!-- Limit the JSR77 categories -->

                     <category name="org.jboss.management">

                        <priority value="INFO"/>

                     </category>

                   

                     <!-- ======================= -->

                     <!-- Setup the Root category -->

                     <!-- ======================= -->

                   

                     <root>

                        <appender-ref ref="CONSOLE"/>

                        <appender-ref ref="FILE"/>

                        <appender-ref ref="SMTP"/>

                     </root>

                   

                  </log4j:configuration>

                   

                  What do you think about my syntax & my problem ?

                   

                  Thanks a lot for your help & best regards

                  • 6. Re: receive a notification by mail when jboss is started
                    wdfink

                    I use your xml with my JBoss, the server.log looks correct.

                     

                    But the SMTP will not fit.

                    - remove SMTP appender from root (it will only heat the CPU)

                       because the appender will create the output and the filter will suppress it.

                    - change category with SMTP from 'org.jboss.system.server.Server' to 'org.jboss.bootstrap.microcontainer.ServerImpl'

                      this will be the class with the INFO start message

                    • 7. Re: receive a notification by mail when jboss is started
                      nortendo

                      Hello Wolf-Dieter (thanks a lot)

                       

                      fine, the server.log works correct.

                       

                      I have done what do you say

                       

                      this the result of my config

                       

                      log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

                       

                         <!-- ================================= -->
                         <!-- Preserve messages in a local file -->
                         <!-- ================================= -->

                       

                         <!-- A size based file rolling appender -->
                         <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
                           <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                           <param name="File" value="${jboss.server.log.dir}/server.log"/>
                           <param name="Append" value="false"/>
                           <param name="MaxFileSize" value="5000000KB"/>
                           <param name="MaxBackupIndex" value="1"/>

                       

                           <layout class="org.apache.log4j.PatternLayout">
                             <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
                           </layout>       
                         </appender>

                       

                         <!-- ============================== -->
                         <!-- Append messages to the console -->
                         <!-- ============================== -->

                       

                         <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
                            <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                            <param name="Target" value="System.out"/>
                            <param name="Threshold" value="INFO"/>

                       

                            <layout class="org.apache.log4j.PatternLayout">
                              <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
                            </layout>
                         </appender>
                             
                         <!-- ================ -->
                         <!-- Limit categories -->
                         <!-- ================ -->

                       

                         <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
                         <category name="org.apache">
                            <priority value="INFO"/>
                         </category>

                       

                         <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
                         <category name="org.jboss.serial">
                            <priority value="INFO"/>
                         </category>

                       

                         <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
                         <category name="org.jgroups">
                            <priority value="WARN"/>
                         </category>

                       

                         <!-- Limit the jacorb category to WARN as its INFO is verbose -->
                         <category name="jacorb">
                            <priority value="WARN"/>
                         </category>

                       

                         <category name="org.jboss.bootstrap.microcontainer.ServerImpl">
                                  <priority value="INFO" />    
                         </category>     
                        
                         <!-- Limit the JSR77 categories -->
                         <category name="org.jboss.management">
                            <priority value="INFO"/>
                         </category>

                       

                         <!-- ======================= -->
                         <!-- Setup the Root category -->
                         <!-- ======================= -->

                       

                         <root>
                            <appender-ref ref="CONSOLE"/>
                            <appender-ref ref="FILE"/>
                         </root>

                       

                      </log4j:configuration>

                       

                       

                      How i can receive an notification by smtp when the jboss is started ? I have stmp service started on localhost

                       

                      Thanks a lot for your help :-)