-
1. Re: receive a notification by mail when jboss is started
wdfink Nov 17, 2010 6:50 AM (in response to nortendo)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 Nov 18, 2010 1:23 AM (in response to wdfink)Nice idea Wolf, i will investigate. Thanks a lot for your response
-
3. Re: receive a notification by mail when jboss is started
nortendo Nov 19, 2010 1:16 AM (in response to 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 Nov 19, 2010 2:20 AM (in response to nortendo)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 Mar 8, 2011 4:17 PM (in response to wdfink)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 Nov 24, 2010 11:14 AM (in response to nortendo)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 Nov 25, 2010 5:11 AM (in response to wdfink)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 :-)