Log4j Module Changes in 7.1.3 Cause Error Logs
tcwang88 Oct 17, 2012 9:45 PMHi,
First of all, here are some background of my purpose for this log4j issue.
I have some log4j.xml files which used to initialize log4j configuration, and I found that I can not use log4j module which JBoss provided because the initialization steps are done before launching my application. The related discussion can be found here: https://community.jboss.org/message/622668#622668#622668
As a result, I exclude jboss log4j module in my jboss-deployment-structure.xml, and create my own log4j module.
Here is my jboss-deployment-structure.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<module name="deployment.log4j">
<resources>
<resource-root path="log4j-1.2.15.jar" />
<resource-root path="PATH_TO_MY_LOG4J_XML_FILES" />
</resources>
<dependencies>
<module name="javaee.api" />
</dependencies>
</module>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
This approach works fine in jboss-as-7.1.1. However, when I tested it in jboss-as-7.1.3, there are couple error logs showing up.
18:23:03,913 ERROR [stderr] (MSC service thread 1-19) log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
18:23:03,914 ERROR [stderr] (MSC service thread 1-19) log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
18:23:03,914 ERROR [stderr] (MSC service thread 1-19) log4j:ERROR [ModuleClassLoader for Module "org.jboss.log4j.logmanager:main" from local module loader @2b76e552 (roots: $JBOSS_HOME/modules)] whereas object of type
18:23:03,914 ERROR [stderr] (MSC service thread 1-19) log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [ModuleClassLoader for Module "deployment.myserver.war:main" from Service Module Loader].
18:23:03,914 ERROR [stderr] (MSC service thread 1-19) log4j:ERROR Could not instantiate appender named "CONSOLE".
In addition, I found that maybe it is because the module changes from 7.1.1 to 7.1.3.
In 7.1.1 org.apache.log4j is a standalone module, but in 7.1.3, the module.xml is like this:
<module-alias xmlns="urn:jboss:module:1.1" name="org.apache.log4j" target-name="org.jboss.log4j.logmanager"/>
Any idea how to get rid of those errors? In addition, does jboss resolve the issue of log4j initialization issue (If I do have some log4j.xml files, how can I let it be configured)
Sincerely,
Tzu-Chi