log4j(dbc) + Hibernate: filtering ONLY sql statments

845 views Asked by At

Good evening everyone. I'm using log4j with log4jdbc to log my application's Hibernate fw. I have this log4j.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n" />
    </layout>
</appender>
<root>
    <priority value="debug" />
    <appender-ref ref="console" />
</root>
</log4j:configuration>

But it is generating a lot of log entries that I don't want to see. I'm interested only in the sql statements. Is there a way of filtering out te ones I dont want?

1

There are 1 answers

3
Radim Köhler On BEST ANSWER

Try to explicitly set the namespace org.hibernate.SQL for your logger (root can target different appender)

<logger name="org.hibernate.SQL">
  <level value="debug" />
  <appender-ref ref="console" />
</logger>