I have a application that I've put together to become familiar with Spring Framework 5, using Maven and Java 8. Once executed, it extracts some information from a PostgreSQL database table and logs it to the console (via slf4j/log4j2).
The actual application logic is working fine - I'm seeing the info retrieved from the database on the console as expected. However, I'm not seeing any of the expected Spring/DBCP2 logging. After the application finishes executing, there are only 15 lines printed on the console - all lines that I specifically logged via logger.debug("...").
The dependencies section of my pom.xml looks like this:
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jdbc</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.1</version>
</dependency>
</dependencies>
A 'mvn dependency:tree' outputs the following...
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building local.spring5 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ local.spring5 ---
[INFO] local.spring5:local.spring5:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.data:spring-data-jdbc:jar:2.3.1:compile
[INFO] | +- org.springframework.data:spring-data-relational:jar:2.3.1:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:2.6.1:compile
[INFO] | +- org.springframework:spring-tx:jar:5.3.15:compile
[INFO] | +- org.springframework:spring-context:jar:5.3.15:compile
[INFO] | | +- org.springframework:spring-aop:jar:5.3.15:compile
[INFO] | | \- org.springframework:spring-expression:jar:5.3.15:compile
[INFO] | +- org.springframework:spring-beans:jar:5.3.15:compile
[INFO] | +- org.springframework:spring-jdbc:jar:5.3.15:compile
[INFO] | +- org.springframework:spring-core:jar:5.3.15:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.15:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.32:compile
[INFO] +- org.postgresql:postgresql:jar:42.3.1:compile
[INFO] | \- org.checkerframework:checker-qual:jar:3.5.0:runtime
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.9.0:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.10.0:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.17.1:compile
[INFO] \- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.17.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.546 s
[INFO] Finished at: 2022-01-15T12:34:04+00:00
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
My log4j2.xml file looks like this...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Configuration>
<Configuration status="INFO" strict="true">
<Properties>
<Property name="CONSOLE_PATTERN">%-5level %c{1} %M - %m%n</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="${CONSOLE_PATTERN}" />
</Console>
</Appenders>
<Loggers>
<Logger name="local.spring5" level="DEBUG" additivity="false">
<AppenderRef ref="STDOUT" />
</Logger>
<Logger name="org.apache.commons.dbcp2" level="DEBUG" additivity="false">
<AppenderRef ref="STDOUT" />
</Logger>
<Logger name="org.springframework" level="INFO" additivity="false">
<AppenderRef ref="STDOUT" />
</Logger>
<Root level="INFO">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
Note that I'm familiar with Spring Framework 3 and for applications based on such, I usually include the log4j-jcl dependency as well. However, https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#spring-jcl suggests that is no longer necessary. I tried adding that dependency as an experiment, but it had no effect.
Does anyone have any ideas on how to get the spring framework/DBCP logging to appear?