Croydon Dias
Croydon Dias

Reputation: 1936

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?

Upvotes: 21

Views: 23551

Answers (6)

engilyin
engilyin

Reputation: 1128

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

Upvotes: 1

Chris Meyer
Chris Meyer

Reputation: 11

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

Upvotes: 0

R Saladi
R Saladi

Reputation: 73

Set the below to false in applications.properties file:

spring.jpa.show-sql=false

it will turn off Hibernation messages.

Upvotes: 6

ezennnn
ezennnn

Reputation: 1437

Solved this by adding:

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

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

Upvotes: 2

Jerry Nerd
Jerry Nerd

Reputation: 51

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

Upvotes: 5

jkraybill
jkraybill

Reputation: 3409

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.

Upvotes: 40

Related Questions