remove hibernate logging from Dropwizard app logs

Viewed 1120

I see a lot of logs logging al the queries that make the logs not very useful. I am trying to remove this logging from my dropwizard app logs I tried to do it through the yml file

logging:
  level: "DEBUG"
  loggers:
    org.hibernate: ERROR

And also in the logback.xml

<logger name="org.hibernate">
        <level value="ERROR" />
    </logger>

I also tried appenders to the yml file as console and syslog. What is the way to remove these SELECT statements from the logs?

I dont want to move the logs to another file as I do want to see the errors

The logger isnt org.hibernate but I only see "Hibernate: select * FROM ....."

3 Answers

You have to set hibernate.show_sql to false

database:
  properties:
    hibernate.show_sql: false

However, this alone may not work. I upvoted the other answer as it led me to this - you do indeed have to pay attention to your configured logging levels for the hibernate package because surprisingly, if your org.hibernate.SQL logging level is set to DEBUG then this will override the hibernate.show_sql: false config and log the SQL anyway!

You need to make sure it's set to INFO or greater

logging:
  loggers:
    "org.hibernate.SQL":
      level: INFO

In my case, setting the "hibernate engine" level (in the application.yaml file) decreased the number of log messages:

loggers:
  org.hibernate.engine: error
Related