Hibernate is using SLF4J I think to send all log messages. So you can configure any SLF4J compatible logging framework.
For example, what I often do is adding logback to my dependencies (I'm using maven) :
Code:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
If you are as lazy as I am you can also add binding that redirect log4j to SLF4J (logback) in case any other library is using log4j :
Code:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.7</version>
</dependency>
Then I also add a binding to redirect java.util.logging to SLF4J:
Code:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.7</version>
</dependency>
And also one that redirect Apache Commons Logging to SLF4J :
Code:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.7</version>
</dependency>
Those 3 other dependencies are not required but with this I'm sure that I can configure only logback and all other log will be redirected to it.
To configure logback check the logback documentation : http://logback.qos.ch/manual/configuration.html
But here's my sample logback.xml (to place at the root of the classpath : ${basedir}/src/main/resource) where I send everything to the STDOUT with a default level of TRACE and filter out packages I doon't want to see with WARN level:
Code:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="demo01" level="trace" />
<logger name="org.hibernate" level="warn" />
<logger name="org.hibernate.SQL" level="debug" />
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="warn" />
<logger name="org.hibernate.type.BasicTypeRegistry" level="warn" />
<logger name="net.sf.ehcache" level="warn" />
<logger name="org.jboss" level="warn" />
<root level="trace">
<appender-ref ref="STDOUT" />
</root>
</configuration>