spring-data-jpa-guide
spring-data-jpa-guide copied to clipboard
日志如何开启
开启事务日志:
logging.level.org.springframework.transaction.interceptor=TRACE
输出格式如下:
2012-08-22 18:50:00,031 TRACE - Getting transaction for [com.MyClass.myMethod]
[my own log statements from method com.MyClass.myMethod]
2012-08-22 18:50:00,142 TRACE - Completing transaction for [com.MyClass.myMethod]
Session Metrics
# Generate and log statistics
spring.jpa.properties.hibernate.generate_statistics=true
logging.level.org.hibernate.stat=DEBUG
15:37:21,964 DEBUG [org.hibernate.stat.internal.StatisticsImpl] - HHH000117: HQL: SELECT a FROM Author a WHERE a.lastName = :lastName, time: 26ms, rows: 1
15:37:21,972 INFO [org.hibernate.engine.internal.StatisticalLoggingSessionEventListener] - Session Metrics {
51899 nanoseconds spent acquiring 1 JDBC connections;
30200 nanoseconds spent releasing 1 JDBC connections;
419199 nanoseconds spent preparing 6 JDBC statements;
21482801 nanoseconds spent executing 6 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;
390499 nanoseconds spent executing 1 flushes (flushing a total of 2 entities and 2 collections);
40233400 nanoseconds spent executing 1 partial-flushes (flushing a total of 2 entities and 2 collections)
}
https://www.baeldung.com/hibernate-logging-levels
https://stackoverflow.com/questions/1965454/showing-a-spring-transaction-in-log