3 Replies Latest reply on Dec 1, 2017 1:47 AM by johnsi george

    wildfly 10 mail logger

    johnsi george Newbie


      can one kindly redirect me to article / sample to send exception in log as mail from wildfly 10 server.

      below is the code tried in jboss 6


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




         <level name="ERROR"/>


               <property name="to">Provide to email address here</property>

               <property name="from">Provide from email address here</property>

               <property name="subject">XXX Error</property>

               <property name="SMTPHost">Provide host name of email</property>

                <property name="SMTPUsername">Provide user email id of host</property>

                 <property name="SMTPPassword">Provide password for the SMTPUsername</property>

               <property name="bufferSize">10</property>



               <pattern-formatter pattern="%d %-5p  %m%n"/>



        • 1. Re: wildfly 10 mail logger
          lukaszracon Newbie

          Try this:

                  <subsystem xmlns="urn:jboss:domain:logging:3.0">

                      <async-handler name="EMAIL">

                          <level name="ERROR"/>

                          <queue-length value="100"/>

                          <overflow-action value="discard"/>


                              <handler name="emailHandler"/>



                      <custom-handler name="emailHandler" class="org.apache.log4j.net.SMTPAppender" module="org.apache.log4j">

                          <level name="ERROR"/>


                              <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>



                              <property name="BufferSize" value="512"/>

                              <property name="To" value="app-exception@example.com"/>

                              <property name="From" value="sysadmin@example.com"/>

                              <property name="Subject" value="[${jboss.node.name}] Application Error"/>

                              <property name="SMTPHost" value="localhost"/>




                          <level name="WARN"/>


                              <handler name="EMAIL"/>




          1 of 1 people found this helpful
          • 2. Re: wildfly 10 mail logger
            James Perkins Master

            I'd suggest using CLI instead of editing the XML. Something like this should achieve the same results and not require shutting down WildFly and restarting it.

            /subsystem=logging/custom-handler=emailHandler:add(class="org.apache.log4j.net.SMTPAppender", module="org.apache.log4j", level=ERROR, named-formatter=PATTERN, properties={BufferSize="512", To="app-exception@example.com", From="sysadmin@example.com", Subject="[${jboss.node.name}] Application Error", SMTPHost="localhost"})
            /subsystem=logging/async-handler=async:add(queue-length=100, overflow-action=discard, handlers=[emailHandler])



            James R. Perkins

            • 3. Re: wildfly 10 mail logger
              johnsi george Newbie

              Thank you.Learned a new stuff.