Logging configuration in Jboss AS 7.1.1

My new work used Jboss Application Server 7.1 for its web applications. One of the things that surprised me was that it was not straightforward to configure webapps to use log4j.properties for logging configuration.

For development, I like to set all logging to ERROR level, except for the packages I’m working on. To achieve this in Jboss, edit the logging subsystem section in the file ${JBOSS_HOME}/standalone/configuration/standalone.xml.

<subsystem xmlns="urn:jboss:domain:logging:1.1">
   <logger category="com.mycompany.project.package">
     <level name="DEBUG"/>
     <level name="ERROR"/>
       <handler name="CONSOLE"/>
       <handler name="FILE"/>

This will be applied to all webapps deployed in the Jboss instance.