如何通过logging.properties启用Hibernate的SQL日志记录? [英] How to enable Hibernate's SQL logging via logging.properties?

查看:623
本文介绍了如何通过logging.properties启用Hibernate的SQL日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从EntityManager的创建中删除了属性 hibernate.show_sql ,并希望用记录级别。我正在使用java的日志工具。

I have removed the property hibernate.show_sql from my EntityManager creation and want to replace it with a logging level. I am using java's logging facility.

正如在这个答案中所解释的,我应该设置 org.hibernate.SQL的日志级别

As explained in this answer I should set the log level of org.hibernate.SQL.

我已经用我的logging.properties试过了,但它不起作用:

I have tried it with my logging.properties, but it doesn't work:

handlers=java.util.logging.ConsoleHandler
org.hibernate.level=FINE
org.hibernate.SQL.level=FINEST
org.hibernate.type.level=FINER

我也尝试了ALL,但没有区别。

I had also tried ALL, but it makes no difference.

有什么不对?

推荐答案

经过一些调试后,我得到了以下配置:

After some debugging I ended up with following configuration:

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=FINE
org.hibernate.level=WARN
org.hibernate.SQL.level=FINE

这篇关于如何通过logging.properties启用Hibernate的SQL日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆