Tuesday, May 20, 2008

Showing the sql queries and values for hibernate queries - Log4j configurations

1. Add folowing to hibernate.properties

2. add following to loj4j.xml

<appender name="trace" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/export/home/log_path/trace.log"/>
<param name="Threshold" value="trace"/>
<param name="DatePattern" value="'.'yyyy-MM-dd-HH'.log'"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p [%t] %c{1} - %m%n"/>

<category name="org.hibernate.type">
<priority value="trace"/>

<category name="org.hibernate.SQL">
<priority value="trace"/>

1 comment:

Thilina Anjitha said...

If you want to avoid printing any logs in the logs files, add folowing to the log4j.xml

<category name="org.hibernate">
<priority value="error"/>