spring.jpa.properties.hibernate.generate_statistics=true不工作

spring.jpa.properties.hibernate.generate_statistics=true不工作,hibernate,spring-boot,jpa,Hibernate,Spring Boot,Jpa,无法启用休眠统计信息 嗨。 我目前正在寻找优化数据库持久性的方法。 我在SpringBoot服务中使用JPA Hibernate,我想检查我的查询是否使用批处理 要检查这一点,我需要启用hibernate统计日志。 我已经在我的application.properties中添加了这两个: spring.jpa.properties.hibernate.generate\u statistics=true logging.level.org.hibernate.stat=debug 但我的应用程序

无法启用休眠统计信息

嗨。 我目前正在寻找优化数据库持久性的方法。 我在SpringBoot服务中使用JPA Hibernate,我想检查我的查询是否使用批处理

要检查这一点,我需要启用hibernate统计日志。 我已经在我的application.properties中添加了这两个:

spring.jpa.properties.hibernate.generate\u statistics=true

logging.level.org.hibernate.stat=debug

但我的应用程序似乎忽略了这些设置

你知道为什么统计数字没有显示出来吗


谢谢。

hibernate-core-5.4.10.Final也有同样的问题,这为我提供了统计信息:

<logger name="org.hibernate.engine.internal.StatisticalLoggingSessionEventListener" level="INFO"/>

我也有类似的问题

尝试检查可能阻止此输出的日志记录配置文件。 简单的方法是禁用日志配置文件,比如重命名它

在我的例子中,我将logback-srping.xml重命名为a-logback-spring.xml。在重新启动我的服务之后。它起作用了


希望这能有所帮助。

可能是您的日志框架正在吞噬所有日志,以防日志级别设置不正确。您好@kedar。我正在使用sl4j和日志级别的infoHi,我也有这个问题。使用SpringBoot2.3.0和spring.jpa.properties.hibernate.generate_statistics=true。其他sql配置可以工作,例如spring.jpa.properties.hibernate.show\u sql=true。还添加到记录器:。有什么想法吗?使用Spring Boot(2.3.1),您可以在应用程序属性文件中使用logging.level.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener=INFO之类的工具来记录统计数据
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)