How to enable HikariCP logging in Spring Boot
Codemia Knowledge Hub ·
Set the com.zaxxer.hikari logger to DEBUG in application.properties or application.yml. HikariCP is Spring Boot's default connection pool, and at DEBUG it logs pool statistics (total, active, idle, waiting), connection lifecycle events and timeout failures, which is what you need to diagnose slow queries, connection leaks and pool exhaustion.
Turning on HikariCP debug logging
application.properties
application.yml
Use DEBUG for troubleshooting and INFO in production. HikariCP's TRACE output is extremely verbose and hurts performance.
Reading the pool stats lines
| Log Entry | Meaning |
total=10 | Total connections in the pool |
active=3 | Connections currently in use |
idle=7 | Connections available for use |
waiting=0 | Threads waiting for a connection |
Added connection | New connection was created |
Timeout failure | Thread could not get a connection in time |
Watch waiting. A non-zero value means the pool is too small or connections are held too long, and it shows up before timeout errors do.
Pool settings that affect the logs
pool-name makes log lines easy to tell apart when there are several pools.
A bigger pool is not always better: each connection uses memory in both the application and the database. Start with maximum-pool-size = (2 * CPU cores) + number_of_disks and tune it with load testing.
connection-timeout is how long a thread waits to get a connection from the pool. It is not a query timeout; that is configured separately, via spring.jpa.properties.jakarta.persistence.query.timeout.
Logging connection leaks
HikariCP can report connections that are borrowed and never returned:
When it detects a leak, HikariCP logs a stack trace of where the connection was acquired:
The trace points at the code that took the connection and did not give it back. Without a threshold, connections held indefinitely (for example from a missing @Transactional or an unclosed resource) quietly exhaust the pool, so set it to 30 to 60 seconds in development.
Reading pool metrics through JMX
Spring Boot Actuator metrics
Query the pool metrics:
Prometheus and Grafana
The key numbers to watch are active connections, idle connections, threads awaiting a connection, and the timeout count.
Logging SQL alongside pool logs
Related reading
- Logical operators for Boolean indexing in Pandas
- Looking for a basic and up-to-date Cassandra tutorial
- Looking for a lightweight-ish distributed DB/cache
- Looking for a mature, scalable GraphDB with .NET or C++ binding
- Logging request/response messages when using HttpClient
- Logging requests being served by tensorflow serving model
- Logic Solving Algorithm for Sudoku in Java
- Lombok 1.18.0 and Jackson 2.9.6 not working together
System design interview problems on this topic
- Design a Distributed OLTP Database: solution and walkthrough
- Design a Wide Column Database: solution and walkthrough
- Design a Key Value Store: solution and walkthrough
- Design a Web Cache: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.