Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off hibernate logging to console

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?

like image 886
Croydon Dias Avatar asked May 16 '11 00:05

Croydon Dias


People also ask

How do I enable hibernate logging in SQL?

The better way to activate the logging of executed SQL statements is to set the log level of the org. hibernate. SQL category to DEBUG (or the corresponding log level of your log framework).

What is logging in hibernate?

Hibernate utilizes Simple Logging Facade for Java (SLF4J) in order to log various system events. SLF4J can direct your logging output to several logging frameworks (NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your chosen binding.


2 Answers

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.

like image 117
jkraybill Avatar answered Oct 10 '22 12:10

jkraybill


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

like image 5
Jerry Nerd Avatar answered Oct 10 '22 14:10

Jerry Nerd