java 关闭休眠日志记录到控制台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6012333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Turn off hibernate logging to console
提问by Croydon Dias
When running my Spring/Hibernate application I see the following unwanted output on the console:
运行 Spring/Hibernate 应用程序时,我在控制台上看到以下不需要的输出:
Hibernate: select securityus0_.ID ....
Hibernate: select securityus0_.ID ....
Hibernate: select securityus0_.ID ....
Hibernate: select securityus0_.ID ....
I have configured my Log4j logger like so:
我已经像这样配置了我的 Log4j 记录器:
<logger name="org.hibernate">
<level value="FATAL"/>
</logger>
<category name="STDOUT">
<priority value="WARN"/>
</category>
<category name="STDERR">
<priority value="WARN"/>
</category>
<!-- for all other loggers log only info and above log messages -->
<root>
<priority value="WARN"/>
<appender-ref ref="STDOUT" />
</root>
How do I silence these messages?
我如何使这些消息静音?
回答by jkraybill
I'm fairly certain that you're seeing those SQL statements because somewhere in your Hibernate config the property "hibernate.show_sql" is set to true. Find that setting and change to false.
我很确定您看到的是这些 SQL 语句,因为在您的 Hibernate 配置中的某处,属性“hibernate.show_sql”设置为 true。找到该设置并更改为 false。
回答by Jerry Nerd
If you have a persistence.xml file try there. That's where I found it.
如果您有persistence.xml 文件,请尝试。那是我找到它的地方。
回答by R Saladi
Set the below to false in applications.properties file:
在applications.properties 文件中将以下设置为false:
spring.jpa.show-sql=false
it will turn off Hibernation messages.
它将关闭休眠消息。
回答by ezennnn
Solved this by adding:
通过添加解决了这个问题:
<property name="hibernate.show_sql" value="false"/>
in the persistence.xml file, this is if you have one
在persistence.xml 文件中,这是如果你有一个
回答by Chris Meyer
If you are using an application.yml
file based on your configuration you may find the property show-sql:true
under the jpa
property.
如果您使用的是application.yml
基于您的配置的文件,您可能会在该属性show-sql:true
下找到该jpa
属性。