19

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Croydon Dias
  • 1,906
  • 5
  • 20
  • 27

5 Answers5

39

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.

jkraybill
  • 3,339
  • 27
  • 32
  • 1
    I do not have a hibernate configuration file. I'm using hibernate annotations together with Spring 3. – Croydon Dias May 16 '11 at 04:57
  • 2
    Check the part of your Spring configuration where you declare the SessionFactory. The 'hibernate.show_sql' property is normally set inside the SessionFactory's 'hibernateProperties'. – teabot Jun 28 '11 at 07:34
  • 5
    The `hibernate.show_sql` property may also be set in `AbstractJpaVendorAdapter.setShowSql(Boolean)` / `HibernateJpaVendorAdapter.setShowSql(Boolean)` – Abdull Nov 09 '12 at 15:17
5

Set the below to false in applications.properties file:

spring.jpa.show-sql=false

it will turn off Hibernation messages.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
R Saladi
  • 63
  • 1
  • 6
5

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

Jerry Nerd
  • 51
  • 1
1

Solved this by adding:

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

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

ezennnn
  • 1,239
  • 11
  • 13
0

If you are using an application.yml file based on your configuration you may find the property show-sql:true under the jpa property.