Turn off hibernate logging to console
Asked Answered
S

6

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?

Smallage answered 16/5, 2011 at 0:56 Comment(0)
Y
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.

Yellowstone answered 16/5, 2011 at 1:37 Comment(3)
I do not have a hibernate configuration file. I'm using hibernate annotations together with Spring 3.Smallage
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'.Vitia
The hibernate.show_sql property may also be set in AbstractJpaVendorAdapter.setShowSql(Boolean) / HibernateJpaVendorAdapter.setShowSql(Boolean)Hutto
S
5

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

Simsar answered 27/6, 2011 at 23:0 Comment(1)
I had <property name="eclipselink.logging.level" value="ALL"/> there. Can be INFO, CONFIG, etc., for less logging.Recite
H
5

Set the below to false in applications.properties file:

spring.jpa.show-sql=false

it will turn off Hibernation messages.

Hawger answered 5/8, 2017 at 4:19 Comment(0)
T
1

Solved this by adding:

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

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

Tradition answered 5/4, 2017 at 15:39 Comment(0)
D
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.

Diaspora answered 10/1, 2020 at 16:54 Comment(0)
Z
0

For me spring.jpa.show-sql=false did not work. However this one did a job:

spring:
  jpa:
    properties:
      hibernate:
        show_sql: false
        format_sql: false
Zendejas answered 8/4 at 12:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.