0
votes

I have a JavaEE/JBoss project. I am having problem configuring JBoss to log using log4j.

This is my log4j.properties under /main/reasources/

log4j.rootLogger=stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c %n%m%C

I also added the jboss-deployment-structure

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

<jboss-deployment-structure>
     <deployment>
        <exclusions>
            <module name="org.apache.log4j"/>
            <module name="org.apache.commons.logging"/>
        </exclusions>
    </deployment>
</jboss-deployment-structure>

I added this line at the oned of standalone.conf that is located under /jboss-eap-6.2/bin

JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.as.logging.per-deployment=true"

I have the dependencies on pom.xml too:

<dependencies>
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-web-6.0</artifactId>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

    </dependencies>

When I run the application, the logging is coming from the default JBoss logging configuration. I cannot change the message format. I also need to log to a syslog server.

1

1 Answers

0
votes

In EAP the property jboss.as.logging.per-deployment=true tells JBoss to ignore the logging configuration set in EAP and configure logging instead as per the deployment descriptor in the project being deployed. So if you are trying to configure logging in JBoss then set that property to false. Set it as a server Host Property. If you are trying to configure logging in the war file that is being deployed, then you would set it to true.