Turn off hibernate logging to console

自作多情 提交于 2019-12-03 15:35:45

问题


When running my Spring/Hibernate application I see the following unwanted output on the console:

Hibernate: select securityus0_.ID ....
Hibernate: select securityus0_.ID ....
Hibernate: select securityus0_.ID ....
Hibernate: select securityus0_.ID ....

I have configured my Log4j logger like so:

   <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?


回答1:


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.




回答2:


If you have a persistence.xml file try there. That's where I found it.




回答3:


Set the below to false in applications.properties file:

spring.jpa.show-sql=false

it will turn off Hibernation messages.




回答4:


Solved this by adding:

<property name="hibernate.show_sql" value="false"/>

in the persistence.xml file, this is if you have one



来源:https://stackoverflow.com/questions/6012333/turn-off-hibernate-logging-to-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!