0 Replies Latest reply on Aug 17, 2011 11:17 AM by mitchelladam83

    JBoss AS 6.0.0.final - log4j won't override if EARClassLoaderDeployer set to "isolated" false

    mitchelladam83 Newbie

      I'm currently migrating a large enterprise app from 4.2.3 to 6.0.0.final and am currently running into a problem using the existing log4j.xml for configuring the logging instead of migrating the (extremely large) file format to the jboss-logging.xml format. This isn't a realistic option as the application is also required to deploy to weblogic.

       

      our log4j.xml is on the root of our ear and the 1.2.15 log4j.jar is in APP-INF/lib with our jboss-app.xml set to use it as its library location.

       

      if deployed using server\default\deployers\ear-deployer-jboss-beans.xml with the setting:

       

         <bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">

            <!-- A flag indicating if ear deployments should have their own scoped

               class loader to isolate their classes from other deployments.

            -->     

            <property name="isolated">true</property>

         </bean>

       

       

      then the log4j.xml is picked up and processed correctly

      however if you change the property to:

       

      <property name="isolated">false</property>

       

      then none of the log4j settings are picked up and all our log4j Loggers redirect to the jboss ones defined in jboss-logging.xml

       

      Our issue with using isolated: true is that our Spring injection is dependant on a single classloader, so in order for the ear to deploy correctly, it must be set to false

       

      I've attached an example ear file showing the problem which shows the way our ear is laid out and configured.

       

      it contains a single session bean SomeBoundBean that outputs log messages on startup and the following log4j configuration:

       

      <?xml version="1.0" encoding="UTF-8" ?>

      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

       

       

      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

        <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

          <param name="Target" value="System.out"/>

          <layout class="org.apache.log4j.PatternLayout">

            <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>

          </layout>

        </appender>

          <appender name="ASYNC_FILE" class="org.apache.log4j.AsyncAppender">

              <param name="BufferSize" value="32"/>

              <param name="Blocking" value="true"/>

              <appender-ref ref="FILE"/>

          </appender>

                <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">

                          <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>

                          <param name="File" value="${jboss.server.home.dir}/log/example.log"/>

                          <param name="Append" value="true"/>

                          <param name="Threshold" value="DEBUG"/>

                          <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>

                          <layout class="org.apache.log4j.PatternLayout">

                                    <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] [%t] %m%n"/>

                          </layout>

                </appender>

        <root>

          <priority value ="debug" />

                <appender-ref ref="ASYNC_FILE"/>

          <appender-ref ref="CONSOLE" />

        </root> 

      </log4j:configuration>

       

       

      with isolated: true, these messages are logged to the example.log file

      with isolated: false, they are displayed on the jboss console and end up in the boot.log

       

      what i really need is a way to enable the log4j configuration, but with isolated classloading set to false.

       

      does anyone know a way that this can be done?