bmlynarczyk
bmlynarczyk

Reputation: 808

JBoss AS 7 Log4j in webapplication not change log level

Here is content of files

classes/log4j.properties

log4j.rootCategory=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

# Enable web flow logging
log4j.category.org.springframework.webflow=DEBUG
log4j.category.org.springframework.faces=DEBUG
log4j.category.org.springframework.binding=DEBUG
log4j.category.org.springframework.transaction=DEBUG

pom.xml

<dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
       <version>1.2.17</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>${org.springframework-version}</version>
   <exclusions>
           <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
           </exclusion>
   </exclusions>
</dependency>

For each dependency which contain commons-logging, SLF4j is make exclusion.

WEB-INF/jboss-deployment-structure.xml

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

When I start server in eclipse on console I still see only INFO log and WARN. I need DEBUG logging spring framework. What's is wrong with this configuration??

Upvotes: 2

Views: 4332

Answers (3)

Mukul Goel
Mukul Goel

Reputation: 8467

Nothing much clear about it. Seems like a bug with AS7

To have app specific logging level you need to

configure in your app in WEB-INF/classes/logging.properties or log4j.properties or log4j.xml

refer ondrej ziska comment at AS7-514 for detailed info

Upvotes: 1

From the JBoss wiki page on configuring your application using log4j at https://docs.jboss.org/author/display/AS71/How+To:

I see in step 2, Include the log4j.properties or log4j.xml file in the lib/ directory in your deployment.

You had your log4j.properties in classes/ directory. Either your log4j properties is not correctly picked up(configuration error)or the documentation is incorrect.

If it does not work from the lib/ directory, the jboss documentation needs to be fixed.

Upvotes: 1

Heinz
Heinz

Reputation: 114

The configuration is included in the logging subsystem of the AS7, e.g. in the domain.xml or standalone.xml depending of the profile and mode.

You need to add a log category for org.spring and increase the log level threshold of the console handler.

<subsystem xmlns="urn:jboss:domain:logging:1.1">
  <console-handler name="CONSOLE">
    <level name="DEBUG"/>
    ...    
  </console-handler>

  ...

  <logger category="org.spring">
    <level name="DEBUG"/>
  </logger>

  ...
</subsystem> 

Upvotes: 0

Related Questions