You can configure your log4j
file with the category tag like this (with a console appender for the example):
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yy-MM-dd HH:mm:ss} %p %c - %m%n" />
</layout>
</appender>
<category name="org.hibernate">
<priority value="WARN" />
</category>
<root>
<priority value="INFO" />
<appender-ref ref="console" />
</root>
So every warning, error or fatal message from hibernate will be displayed, nothing more. Also, your code and library code will be in info level (so info, warn, error and fatal)
To change log level of a library, just add a category, for example, to desactive spring info log:
<category name="org.springframework">
<priority value="WARN" />
</category>
Or with another appender, break the additivity (additivity default value is true)
<category name="org.springframework" additivity="false">
<priority value="WARN" />
<appender-ref ref="anotherAppender" />
</category>
And if you don't want that hibernate log every query, set the hibernate property show_sql
to false
.