Walking Corpse
Walking Corpse

Reputation: 73

No logging happens for jdbc in springboot

In my application.properties I have

log4j.category.org.springframework.jdbc.core = TRACE
log4j.logger.org.springframework.jdbc=DEBUG

and the below dependencies in my pom.xml:

 <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

But no logging happens for jdbc statements, although my main application's INFO level logs are appearing. What could cause this?

Upvotes: 0

Views: 475

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116061

To configure log levels in Spring Boot, you should use properties with the form logging.level.<logger-name>=<level>. For your two loggers, the properties should be:

logging.level.org.springframework.jdbc.core=TRACE
logging.level.org.springframework.jdbc=DEBUG

You can learn more in the relevant section of the Spring Boot reference documentation.

Upvotes: 1

Related Questions