When does Hibernate print statistics?

When you enable hibernate statistics you get session statistics information every time a session is closed. if you dont want this behavior you can disable it with adding of following entry in your log4j file:

log4j.logger.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener=OFF

If you don't want to get to as deep as session events, you can disable them from getting logged by using this property "hibernate.session.events.log=false". (You may do it with your log4j configuration also, based on your needs).

It appears that since hibernate 4, if you enable "hibernate.generate_statistics", the session events are also logged by default. But the logs will get filled up heavily as the events are logged per session. So, use when you need to analyze any performance issues locally.

More details on enabling/disabling the event logs here: https://hibernate.atlassian.net/browse/HHH-8793

Tags:

Java

Hibernate