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

问题描述

我已经设置了

  

将时,不要将 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可以)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 20:31