Can't enable hibernate statistics
Hi. I'm currently looking for ways to optimize my database persistence. I'm using JPA Hibernate in my SpringBoot service and I want to check if my queries are using batch processing.
To check that, I need to enable the hibernate statistics logs. I have already added these two in my application.properties:
spring.jpa.properties.hibernate.generate_statistics=true
logging.level.org.hibernate.stat=debug
But it seems that my application disregards these settings.
Do you have any idea why the statistics do not show?
Thank you.
Had the same issue with hibernate-core-5.4.10.Final and this enabled the statistics for me:
<logger name="org.hibernate.engine.internal.StatisticalLoggingSessionEventListener" level="INFO"/>
Example output in my log file:
2020-02-13 17:27:57,188 [main] INFO (o.h.e.i.StatisticalLoggingSessionEventListener:258 end) - Session Metrics {
700 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
2500 nanoseconds spent preparing 1 JDBC statements;
678100 nanoseconds spent executing 1 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
939200 nanoseconds spent executing 1 flushes (flushing a total of 1 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With