JBoss 7: Equivalent to jboss-log4j.xml

I don't want to set up logging with standalone.xml or the CLI as it takes extra steps for my colleagues to get a working development environment. I want these config files to be validated with our source code and automatically applied during deployment.

With JBoss 5, it is possible to declare an entry in jboss-log4j.xml. Is there an equivalent to this file in JBoss 7?

We want to use slf4j and logback.

+3


source to share


2 answers


You can add log configuration to your application. You will need to enable login in the application. You might have to use jboss-deployment-structure.xml , similar to log4j exception , to exclude the module org.slf4j

. This will only set up logging for your application.

If you are concerned that you have just configured the logging subsystem, there are a couple more options that might work depending on your environment.

The first one, and one that will work with any environment, will generate a CLI script that can be tested and run.



${JBOSS_HOME}/bin/jboss-cli.sh --connect --file path/to/script.cli

      

If you are using maven the second option would be to use the maven plugin . You can execute console commands using a plugin. Just add a target execute-commands

to run before starting the deployment target.

+3


source


If you want to use your own logging rather than JBoss logging, there are a couple of steps you need to take for each application you want to do yourself:

Exclude JBoss Logging

Take note of the jboss-deployment-structure.xml file to exclude jboss log4j or slf4j or any other logging modules included with JBoss.

Example for WAR ... place in WAR / WEB-INF /

<jboss-deployment-structure>
    <deployment>
        <exclusions>
            <module name="org.slf4j"/>
        </exclusions>
    </deployment>
</jboss-deployment-structure>

      

Include your own banks

Just place your own jars in lib folder

For WAR, place in WAR / WEB-INF / lib

Enable logging configuration

Just include your own config files like normal

For WAR, place in WAR / WEB-INF / classes



Start JBoss with the -D flag

Start the server using:

$ ./standalone.sh -Dorg.jboss.as.logging.per-deployment=false

      

Example for EAR

Place jboss-deployment-structure.xml in EAR/META-INF

<jboss-deployment-structure>
    <sub-deployment name="myWar.war>
        <exclusions>
            <module name="org.slf4j"/>
        </exclusions>
    </sub-deployment>
    <sub-deployment name="myWar2.war>
        <exclusions>
            <module name="org.slf4j"/>
        </exclusions>
    </sub-deployment>
    <sub-deployment name="myEjb.jar>
        <exclusions>
            <module name="org.slf4j"/>
        </exclusions>
    </sub-deployment>
</jboss-deployment-structure>

      

In EAR/lib

turn JARS

In each deployment, add configuration/properties

for this deployment

Start the server: $./standalone.sh -Dorg.jboss.as.logging.per-deployment=false

This was to change the version of the JARs JARs to your own, so you can get your own JARs and config files. Let me know if you have any questions.

+6


source







All Articles