3 Replies Latest reply on Dec 27, 2007 6:42 AM by jismolv

    log4j with jboss issue ?

    jsbhangra

      I tried to use log4j with my web application deployed on JBoss..
      but JBoss did not permit it . so i configured JBoss logging in my application as in this link :http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigureLogging...

      Every thing worked fine , but now i want to use MDC( mapped diagnostic context ) technique of log4j in my application .. which is not permitted in JBoss logging..

      So to configure log4j loging support i did following :
      1.Renamed log4j.xml in JBOSS_HOME/server/default/conf to jboss-log4j.xml
      2.Changed jboss-service.xml in JBOSS_HOME/server/default/conf accordingly to tell JBoss to use jboss-log4j.xml
      3. Added following code jboss-web.xml

      <class-loading java2ClassLoadingCompliance="false">
       <loader-repository>
       testlogapp:loader=testlogappwar
       <loader-repository-config>java2ParentDelegation=false
       </loader-repository-config>
       </loader-repository>
       </class-loading>
      


      4. added my own log4j.xml in WEB-INF directory for my application...
      Every thing else works fine but is not my application logs are not being generated ...

      The following exception is generated :
      
      13:26:43,234 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
      13:26:43,235 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
      13:26:43,235 ERROR [STDERR] log4j:ERROR [WebappClassLoader
       delegate: false
       repositories:
       /WEB-INF/classes/
      ----------> Parent Classloader:
      java.net.FactoryURLClassLoader@fe7f80
      ] whereas object of type
      13:26:43,236 ERROR [STDERR] log4j:ERROR "org.jboss.logging.appender.FileAppender" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@c2a132].
      13:26:43,236 ERROR [STDERR] log4j:ERROR Could not instantiate appender named "FILE".



      Please help me out ...

        • 1. Re: log4j with jboss issue ?
          bensonfungjava

          Hi,

          I followed two approaches documented by JBOSS, i.e. RepositorySelector and MDC. Both don't work. Dont' work means it didn't generate my application owned log file. To bad


          Benson

          • 2. Re: log4j with jboss issue ?

            We all are having the same problem.
            It seem impossible to override log4j.jar despite the wiki explanations about that.
            The only one solution is to remove your log4j version and to let the one with is jboss server lib to be loaded.
            This is a ugly solution.
            Jboss guys have to tells us why the make things as painfull as that.

            Meissa

            • 3. Re: log4j with jboss issue ?
              jismolv

              Did you solve this problem? Even i am facng the same problem. It would be of great help if you could share how you overcame this issue.