3 Replies Latest reply on Jul 1, 2017 3:29 PM by James Perkins

    Log4j2 configuration in JBoss EAP 7

    Chin T Newbie

      Hi,

       

      I am new to JBoss. As part of Jboss migration I have to configure Log4j2 in JBoss. Can some body suggest me how to start with this?

        • 1. Re: Log4j2 configuration in JBoss EAP 7
          Anup Dey Apprentice

          You could add the following to your jboss-deployment-structure.xml (included in the war):

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

          <jboss-deployment-structure>

             <deployment>

                <!--

                Prevent that the server add automatically dependencies -->

                <!-- Exclude all logging dependencies so we can use log4j2 -->

                <exclusions>

                   <module name="org.apache.commons.logging" />

                   <module name="org.apache.log4j" />

                   <module name="org.jboss.logging" />

                   <module name="org.jboss.logging.jul-to-slf4j-stub" />

                   <module name="org.jboss.logmanager" />

                   <module name="org.jboss.logmanager.log4j" />

                   <module name="org.slf4j" />

                   <module name="org.slf4j.impl" />

                </exclusions> 

             </deployment>

          </jboss-deployment-structure>

          Then you could include the log4j2 jar in your application and put the log4j2 config file in a file system folder if you add an apprpriate module definition.

          This all depends though on the logging api that your application is using - e.g. against which api it is compiled. If you can change it I'd suggest to use slf4j that would be the most flexible solution.

          1 of 1 people found this helpful
          • 2. Re: Log4j2 configuration in JBoss EAP 7
            Chin T Newbie

            Thank you Anup. I will work on it and update on the same. As per our requirement we should use log4j2 with JBoss.

            • 3. Re: Log4j2 configuration in JBoss EAP 7
              James Perkins Master

              Instead of excluding each module you could just exclude the logging subsystem which would stop all the logging dependencies from being added to your deployment.

              <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure>    <deployment>       <exclude-subsystems>          <subsystem name="logging"/>       </exclude-subsystems>    </deployment> </jboss-deployment-structure>

              --

              James R. Perkins