5 Replies Latest reply on Mar 18, 2005 3:30 PM by Bruno Melloni

    Problems with log4j and EAR deployment

    Sean Garagan Newbie

      Good day,

      I am trying to get a per-ear deployment working and while I believe I have all the parts as explained ini the Wiki and other forums, I do not get any output files created at all.

      I have renamed conf/log4j.xml to jboss-log4j.xml and made the appropriate change in jboss-service.xml. My EAR has the following jboss-app.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 1.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd">
       <jboss-app>
       <class-loading java2ClassLoadingCompliance="false">
       <loader-repository>
       trade6:loader=trade6.ear
       <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
       </loader-repository>
       </class-loading>
       </jboss-app>
      


      I have log4j-1.2.8.jar in my EAR root, along with log4j.xml. The log4j-1.2.8.jar is referenced by the manifest classpath of the deployed EJB jar file. My log4j.xml is:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <!-- ===================================================================== -->
      <!-- -->
      <!-- Log4j Configuration -->
      <!-- -->
      <!-- ===================================================================== -->
      
      <!--
       This is a per-application log configuration. Changes to this file will
       only affect the application it is deployed with.
       -->
      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
      
       <!-- ================================= -->
       <!-- Preserve messages in a local file -->
       <!-- ================================= -->
      
       <!-- A time/date based rolling appender -->
       <appender name="SERVER_FILE" class="org.apache.log4j.RollingFileAppender">
       <param name="File" value="C:/Versata/VLS-6.0-JBoss/Config/server/default/log/vls-server.log"/>
       <param name="Append" value="false"/>
       <param name="Threshhold" value="DEBUG"/>
       <param name="MaxFileSize" value="100MB"/>
       <param name="MaxBackupIndex" value="1"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <!-- The default pattern: Date Priority [Category] Message\n -->
       <param name="ConversionPattern" value="%d{ISO8601} %-4r %-5p %c{8} %x - %m\n"/>
       </layout>
       </appender>
      
       <appender name="RCS_FILE" class="org.apache.log4j.RollingFileAppender">
       <param name="File" value="C:/Versata/VLS-6.0-JBoss/Config/server/default/log/rcs-server.log"/>
       <param name="Append" value="false"/>
       <param name="MaxFileSize" value="100MB"/>
       <param name="MaxBackupIndex" value="1"/>
      
       <layout class="org.apache.log4j.PatternLayout">
       <!-- The default pattern: Date Priority [Category] Message\n -->
       <param name="ConversionPattern" value="%-30.30c %t %m\n"/>
       </layout>
       <filter class="com.versata.tl.common.vstrace.logger.VSTraceFilter"
       </appender>
      
       <renderer
       renderedClass="com.versata.tl.common.vstrace.impl.VSTraceRecord"
       renderingClass="com.versata.tl.common.vstrace.logger.VSTraceRecordRenderer"/>
      
       <category name="com.versata.tl">
       <priority value="DEBUG"/>
       </category>
      
       <category name="versata.trace.rcs">
       <priority value="TRACE#com.versata.tl.api.logging.TraceLevel"/>
       <appender-ref ref="RCS_FILE"/>
       </category>
      
       <root>
       <level value="INFO"/>
       <appender-ref ref="PROJECT_FILE"/>
       </root>
      </log4j:configuration>
      


      When I deploy the app, it looks like the ear configuration is not read at all. There is no log4j debug output and no files are created at all.

      It is probably something simple I am missing but I cannot figure it out.

      Thanks in advance,
      Sean

        • 1. Re: Problems with log4j and EAR deployment
          viz Newbie

          I am having the same problem, but it only works for me when I explode both the EAR and the WAR (not using an EJB) in the deploy directory.

          I have log4j.jar in the root of the EAR and the log4j.xml in a directory called 'properties' which is in the root of the EAR.

          The MANIFEST.MF for the WAR has the following entry:

          Class-Path: ./properties ./log4j.jar

          As I say, this all works fine, until the an actual WAR is deployed rather than an archive.

          • 2. Re: Problems with log4j and EAR deployment
            Sean Garagan Newbie

            Good day,

            Hmm...an exploded ear still seems to cause problems. If I have the following jboss-app.xml in the ear, nothing happens (it does not read the log4j.xml)

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 1.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd">
             <jboss-app>
             <class-loading java2ClassLoadingCompliance="false">
             <loader-repository>
             trade6:loader=trade6.ear
             <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
             </loader-repository>
             </class-loading>
             </jboss-app>
            


            but when I remove the <class-loading> element from that file, I get the following (well known) exception:

            Caused by: java.lang.ClassCastException
             at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
             at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:644)
             at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
             at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:602)
             at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:460)
             at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
             ... 133 more
            


            Has anyone been able to get per-ear log4j configuration working with only EJBs deployed in the ear (no war files)?

            Thanks,
            Sean

            • 3. Re: Problems with log4j and EAR deployment
              viz Newbie

              I solved my issue by moving to 4.0.1sp1. Might be worth a try?

              • 4. Re: Problems with log4j and EAR deployment
                Bruno Melloni Newbie

                Try using a log4j.xml file name other than log4j.xml. Maybe log4j.xml. You might be somehow "finding" first jBoss' log4j.xml instead of yours.