While moving our current logging to use SLF4J (with log4j) I found that it won't log to the appender for commons-logging in my appache server. When it hits the commons logging (this specific example is in the TextProviderHelper class), it has the properly injected logger, and with the right logging level, but does not show up in the system.out. Here's my setup:
pom.xml:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
log4j.xml:
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<param name="Threshold" value="ERROR" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n" />
</layout>
</appender>
<logger name="org.apache.struts2.util.TextProviderHelper" additivity="false">
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
<appender-ref ref="consoleAppender" />
</logger>
If I see this correctly, only messages with ERROR or higher level (FATAL?) go the the appender due to its Threshold, so no INFO, WARN, DEBUG ....