如何为日志记录启用休眠查询计时



我正在尝试为休眠查询添加计时统计信息机制。我们的 application.properties 文件已经有这样的条目:

logging.level.org.hibernate.SQL=DEBUG
spring.jpa.hibernate.ddl-auto=validate

所以我试图添加:logging.level.org.hibernate.stat=DEBUG。但这并没有为我提供任何时间信息。有人知道为什么吗?

编辑:我也把它添加到pom.xml:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <java.version>1.8</java.version>
  <hibernate.generate_statistics>true</hibernate.generate_statistics>
</properties>

仍然不起作用。

还需要设置休眠系统属性: hibernate.generate_statistics=true

设置系统属性的一种方法是使用 VM 参数。在您的情况下:-Dhibernate.generate_statistics=true

最新更新