how to send mail for log level ERROR in JBoss EAP6.1.0 (AS 7.2.0 Final Redhat 8)

2k views Asked by At

Hi We are using JBoss EAP 6.1.0 for our project, i am trying to find a way to configure sending emails for loglevel ERROR in standalone.xml but i didn't fine any documentation which provides some example i added the below configuration to my standalone.xml but i am getting parsing exception after that.

Here is my code:

<subsystem xmlns="urn:jboss:domain:logging:1.2">
            <console-handler name="CONSOLE">
                [Some Code Here]
            </console-handler>
            <custom-handler name="EMAIL" class="org.apache.log4j.net.SMTPAppender" module="org.apache.log4j">
                <level name="ERROR"/>
                <formatter>
                    <pattern-formatter pattern="%d %-5p [%c] %m%n"/>
                </formatter>
                <properties>
                    <property name="BufferSize" value="10"/
                    <property name="SMTPHost" value="localhost"/>
                    <property name="From" value="[email protected]"/>
                    <property name="To" value="[email protected]"/>
                    <property name="Subject" value="SWS Error Log"/>
                </properties>
            </custom-handler>
            <periodic-rotating-file-handler name="FILE">
                <formatter>
                    <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append value="true"/>
            </periodic-rotating-file-handler>
            <logger category="com.arjuna">
                <level name="WARN"/>
            </logger>
            <logger category="org.apache.tomcat.util.modeler">
                <level name="WARN"/>
            </logger>
            <logger category="sun.rmi">
                <level name="WARN"/>
            </logger>
            <logger category="jacorb">
                <level name="WARN"/>
            </logger>
            <logger category="jacorb.config">
                <level name="ERROR"/>
            </logger>           
            <root-logger>
                <level name="INFO"/>
                <handlers>
                    <handler name="CONSOLE"/>
                    <handler name="FILE"/>
            <handler name="EMAIL"/>
                </handlers>                             
            </root-logger>
        </subsystem>

Exception I am getting:

JBAS014789: Unexpected element '{urn:jboss:domain:logging:1.2}handler-ref' encountered

Help in providing suggestions/solution is much appreciated.

2

There are 2 answers

0
Philippe Marschall On

JBoss AS 7 no longer uses log4j. It uses jboss-logging which seems to delegate to ava.util.logging.Handlers see also https://github.com/jboss-logging/jboss-logmanager/tree/master/src/main/java/org/jboss/logmanager/handlers.

0
HansElsen On

Maybe you already have the answer, but your xml is not valid.

<properties>
    <property name="BufferSize" value="10"/ <--- missing character
    <property name="SMTPHost" value="localhost"/>
    <property name="From" value="[email protected]"/>
    <property name="To" value="[email protected]"/>
    <property name="Subject" value="SWS Error Log"/>
</properties>