3 Replies Latest reply on Aug 11, 2005 3:48 AM by jaikiran pai

    My own Log4j.properties for Jboss 3.2.3

    jaikiran pai Master

      I need to create my own custom appender which will extend from org.apache.log4j.FileAppender.
      If i make an entry for the same in the log4j.xml of conf directory as below:

      <appender name="PE_LOG" class="com.myPackage.myAppender">

      Then i will get ClassNotFoundException for obvious reasons as my classes havent yet been loaded when log4j service is being started.

      So i did the following, which was mentioned at:
      http://www.jboss.org/wiki/Wiki.jsp?page=Logging (Section: Using your own log4j.properties classloader scoping)

      I followed exactly what is mentioned in this link. However, the server is NOT considering my log4j.properties file. Its just ignoring it.

      I have the following structure in my application:
      |--- WEB-INF\classes\log4j.properties
      |--- WEB-INF\log4j.jar

      myApp.war is inside myProject.ear

      The contents of my log4j.properties are:

      #Appender Configuration
      log4j.rootLogger=ERROR, ROOT
      #Layout Configuration
      log4j.appender.ROOT.layout.ConversionPattern=%d %-5p [%c] %m%n
      log4j.appender.PE.layout.ConversionPattern=%d %-5p [%c] %m%n

      Contents of jboss-web.xml:

       <class-loading java2ClassLoadingCompliance="false">

      Has anyone tried out this before. Can anyone please tell me why the log4j.properties is never considered.
      I am using jboss-3.2.3

      Thank you

        • 1. Re: My own Log4j.properties for Jboss 3.2.3
          Andy Nguyen Newbie

          Did you rename conf/log4j.xml to something else (like conf/jboss-log4j.xml) and update conf/jboss-service.xml to match? Also, I think log4j.jar should go in WEB-INF/lib.

          • 2. Re: My own Log4j.properties for Jboss 3.2.3
            jaikiran pai Master

            Ya, i did rename the log4j.xml in conf directory to jboss-log4j.xml.

            Regarding, placing the log4j.jar in WEB-INF/lib directory, i will try it out.

            I have a small doubt though:

            - I DONT have my class files under WEB-INF/classes in myApp.war.
            - The class files are placed in a myEjb.jar and myCommon.jar
            - These 2 two jars are then placed in my ear file as follows:

            |---- myEjb.jar
            |---- myCommon.jar

            So, does specifying different classloader in the myApp.war, really make a difference.

            If NO, how do we achieve maintaining our own log4j.properties in a J2EE application for ejbs.

            Thank you.

            • 3. Re: My own Log4j.properties for Jboss 3.2.3
              jaikiran pai Master

              Got it working. I did the following:

              Placed log4j.jar and log4j.xml in myApp.ear. Then made the following entry in application.xml:


              Also, renamed log4j.xml to jboss-log4j.xml in conf directory of jboss, and correspondingly changed jboss-service.xml in conf directory.