无法阻止Hibernate将日志写入控制台(log4j.properties可以) [英] Can't stop Hibernate from writing log to console (log4j.properties is ok)

查看:160
本文介绍了无法阻止Hibernate将日志写入控制台(log4j.properties可以)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了

 < property name =show_sql> false< / property> 

我禁用了log4j.properties中的所有消息

但是Hibernate用所有查询和放大器写入控制台。

解决方案

hibernate.show_sql 设置为 true 将hibernate告诉将所有SQL语句写入控制台。这是将日志类别 org.hibernate.SQL 设置为debug的替代方法。



即使您将此属性设置为 false ,请确保您没有定义以下类别(或配置为使用控制台appender):

  log4j.logger.org.hibernate.SQL = DEBUG 

另外,确保在实例化配置时,不要将 hibernate.show_sql code>对象。寻找类似这样的东西:

 配置cfg = new Configuration().configure()。 
.setProperty(hibernate.show_sql,true);

注意 setProperty(String propertyName,String value)将第一个参数作为配置属性的全名,例如 hibernate.show_sql ,而不仅仅是 show_sql


I've already set

<property name="show_sql">false</property>

and I have disabled all messages in log4j.properties

But Hibernate write to console with all queries & statements.

解决方案

Setting the hibernate.show_sql to true tells hibernate to Write all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL to debug.

So even if you set this property to false, make sure that you don't have the following category defined (or configured to use a console appender):

log4j.logger.org.hibernate.SQL=DEBUG

Also, make sure that you don't set the hibernate.show_sql programmatically to true when instancing your Configuration object. Hunt something like this:

Configuration cfg = new Configuration().configure().
    .setProperty("hibernate.show_sql", "true");

Note that the setProperty(String propertyName, String value) takes as first parameter the full name of a configuration property i.e. hibernate.show_sql, not just show_sql.

这篇关于无法阻止Hibernate将日志写入控制台(log4j.properties可以)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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