1 Reply Latest reply: Oct 21, 2011 3:53 PM by Scott Marlow RSS

logging hibernate sql statement with parameters

Sam W Expert

Hi,

 

With jboss as7.1A, how to log hibernate sql statment with parameters display on console?

 

I have the log4j.xml file in-placed under java/resources/META-INF folder, shown as below:

 

 

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"

    debug="false">

    <appender name="DAILY-ASYNC" class="org.apache.log4j.AsyncAppender">

        <param name="LocationInfo" value="false" />

        <appender-ref ref="DAILY-TOMCAT-FILE" />

    </appender>

    <appender name="DAILY-TOMCAT-FILE" class="org.apache.log4j.DailyRollingFileAppender">

        <param name="DatePattern" value="'.'yyyy-MM-dd" />

        <param name="File" value="../standalone/log/category6-ws-ejb.log" />

        <layout class="org.apache.log4j.PatternLayout">

            <param name="ConversionPattern" value="%d{ISO8601} [%-5p] [%t] %c - %m%n" />

        </layout>

        <filter class="org.apache.log4j.varia.LevelRangeFilter">

            <param name="LevelMin" value="DEBUG" />

            <param name="LevelMax" value="FATAL" />

        </filter>

    </appender>

    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

        <layout class="org.apache.log4j.PatternLayout">

            <param name="ConversionPattern" value="%d{ISO8601} [%-5p] [%t] %c - %m%n" />

        </layout>

    </appender>

    <category name="org.hibernate.SQL">

       <priority value="TRACE"/>

       <appender-ref ref="CONSOLE"/>

   </category>

 

 

   <category name="org.hibernate.type">

       <priority value="TRACE"/>

       <appender-ref ref="CONSOLE"/>

   </category>

    <logger name="ix.houseware.category">

        <level value="DEBUG" />

    </logger>

    <logger name="org.springframework.web.portlet">

        <level value="DEBUG" />

    </logger>

    <logger name="org.springframework.web.servlet.ViewRendererServlet">

        <level value="DEBUG" />

    </logger>

    <root>

        <level value="DEBUG" />

        <appender-ref ref="DAILY-ASYNC" />

        <!--  appender-ref ref="CONSOLE" /-->

    </root>

</log4j:configuration>

 

 

But it doesn't show the parameter that come with the hibernat sql logging.

 

Any suggestion would be very appreciated.

 

Thanks

Sam