1 Reply Latest reply on Apr 5, 2012 12:21 PM by jamezp

    How to setup log4j with JBoss AS 7

    foutjo

      I want to use log4j instead of jboss logging for logging.

       

      Can someone please point me to the documentation to do this?

      I found some docs but they were a bit confusing for me to firgure out how to setup.

       

      A few questions:

       

      1.  Where does the log4j jar file go?

      2.  Where does the log4j properties file go?

      3.  Do yo have to modify the server startup file(standalone.xml)?

       

      Any help is greatly appreciated.

       

      Thanks.

        • 1. Re: How to setup log4j with JBoss AS 7
          jamezp

          I firstly want to point out that other log frameworks can be used with no problems, but you will not have the ability to configure logging for your application through the console if you use your own handlers/appenders.

           

          1.  Where does the log4j jar file go?

          If you want to use your own configuration file you need to package log4j in WEB-INF/lib in your WAR file.

           

           

          2.  Where does the log4j properties file go?

          Same place you would normally put it for a log4j. In a WAR IIRC it should be in WEB-INF/classes.

           

           

          3.  Do yo have to modify the server startup file(standalone.xml)?

          You don't need to modify standalone.xml at all. You will need to include a jboss-deployment-structure.xml with your deployment though. You can get more information on that here https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7#ClassLoadinginAS7-JBossDeploymentStructureFile

           

          Your jboss-deployment-structure.xml would look something like the following.

           

          <jboss-deployment-structure>
              <deployment>
              <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
                  <exclusions>
                      <module name="org.apache.log4j" />
                  </exclusions>
              </dependencies>
          </jboss-deployment-structure>