How to use Custom Log4j Appender as custom-handler in EAP6.1
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.1
Issue
- Is there a way to configure "org.apache.log4j.FileAppender" as a "custom-handler" in EAP6.1
- In previous JBoss versions, we have used log4j and taken advantage of the SmtpAppender to email errors of a certain severity level. How would you recommend that we implement this email functionality in EAP 6.2?
Resolution
- Try adding the following configuration inside your EAP6.1 configuration file inside the logging subsystem.
<subsystem xmlns="urn:jboss:domain:logging:1.2">
<custom-handler name="log4jAppender" class="org.apache.log4j.FileAppender" module="org.apache.log4j">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<level name="INFO"/>
<properties>
<property name="append" value="true"/>
<property name="file" value="${jboss.server.log.dir}/log4j.log"/>
<property name="immediateFlush" value="true"/>
</properties>
</custom-handler>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="log4jAppender"/>
</handlers>
</root-logger>
</subsystem>
Related Solution:
How do I use a Log4J appender as a custom handler in JBoss EAP 6?
https://access.redhat.com/site/solutions/286583
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments