Monday, 11 May 2015

Application logging is not working in jBoss

Custom application logging was not creating a separate log file, but instead it was writing in the jBoss logging.

The default behavior of jBoss is that the custom log or stdout everything goes into the jBoss server logging or on the console. The only way to say to the server not to write our logging into the console, add the following piece of code in the Web project.

Create a jboss-deployment-structure.xml with the following content and place it in the META-INF/ directory if you are deploying an EAR or in either the META-INF/ or WEB-INF/ directory if you are deploying a WAR. Add the following content into the above file.

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


Include the log4j.properties or log4j.xml file in the src/ directory in your deployment (to make sure its available in the classpath).
Deploy your application.

No comments:

Post a Comment