log4jwildflywildfly-8jboss-logging

Adding SMTP log handler in Wildly 8.1


I have been through lot of WildFly documentation in past day and so far I have failed to understand how a SMTP Handler could be added to WildFly logging sybsystem. This was very easy when JBoss used log4j but now there are hardly any documentation available.

Places I have already looked at: https://docs.jboss.org/author/display/WFLY8/Logging+Configuration

There is support of using a Custom Log handler. as mentioned jira https://issues.jboss.org/browse/AS7-1438 but are there any examples available? can log4j SMTP handler be used here?

Is this the best solution available? https://developer.jboss.org/wiki/CreatingACustomLoggingHandlerInJBOSSAs710Final


Solution

  • How about this one with jboss-cli:

    /subsystem=logging/custom-handler=LOG4J_SMTP:add( \
     class="org.apache.log4j.net.SMTPAppender", \
     module="org.apache.log4j", \
     formatter="%-5p [%c] (%t) %s%e", \
     level=INFO, \
     properties={ \
      From="jane.doe@gmail.example.com", \
      LocationInfo=true, \
      SMTPDebug=true, \
      SMTPHost="smtp.gmail.com", \
      SMTPPort=465, \
      SMTPProtocol="smtps", \
      SMTPUsername="jane.doe@gmail.example.com",  \
      SMTPPassword="***", \
      Subject="error mail subject", \
      To="jane.doe@icloud.example.com", \
      BufferSize=256 })
    

    For configuration details see: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SMTPAppender.html