-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Logging Hibernate generated SQL with logback
PostPosted: Tue Jun 24, 2008 7:14 am 
Newbie

Joined: Tue Jun 24, 2008 6:55 am
Posts: 4
Location: Mumbai
I have a web application deployed on tomcat that uses hibernate and spring. I am using logback as my logging api.

This is my logback.xml file which i have placed in classes folder (so wd be in web application classpath, and thus configured automatically)

Code:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <appender name="File" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <File>mylog.log</File>
      <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
         <FileNamePattern>mylog.%i.log.zip</FileNamePattern>
         <MinIndex>1</MinIndex>
         <MaxIndex>5</MaxIndex>
      </rollingPolicy>
      <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
         <MaxFileSize>5MB</MaxFileSize>
      </triggeringPolicy>
      <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{yyyy/MM/dd HH:mm:ss} [%thread] %-5p %c - %m%n</pattern>
      </layout>
   </appender>

    <!-- Hibernate Loggers -->
    <logger name="org.hibernate.type">
        <level value="DEBUG" />
        <appender-ref ref="File" />
    </logger>

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

    <logger name="sql-log">
        <level value="DEBUG" />
        <appender-ref ref="File" />
    </logger>

    <logger name="package.to.hold.my.classes">
       <level value="DEBUG" />
       <appender-ref ref="File" />
    </logger>

    <root>
   <level value="info" />
   <appender-ref ref="File" />
    </root>
</configuration>


The issue is although i can see debug and above level logs generated by classes with in package.to.hold.my.classes.... I cant see any sql and parameter/return types being logged in the log file.

Here is the part of code from spring applicationContext file that configures sessionfactory
Code:
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        ............
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.SybaseDialect</prop>
                <prop key="show_sql">false</prop>
            </props>
        </property>
    </bean>


I have already tried settting show_sql to true and false but it did not work. Also tried both console and file appenders and neither worked.

Please let me know your views, any direction wd be highly appreciated.

_________________
Sanchit Srivastava


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 7:06 pm 
Newbie

Joined: Sun Oct 05, 2008 4:32 pm
Posts: 3
Me neither. I have the same problem, did anyone solved this? Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 4:21 am 
Newbie

Joined: Tue Jul 01, 2008 7:30 am
Posts: 11
Location: Pune,India
I had same prob, i solved same using following setting in my log4j.proerties file
log4j.logger.org.hibernate.SQL=DEBUG
log4j.additivity.org.hibernate.SQL=true


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2008 10:14 am 
Newbie

Joined: Sun Oct 05, 2008 4:32 pm
Posts: 3
solution for logback is to set org.hibernate.type to trace in logback.xml - debug is not enough

<logger name="org.hibernate.type">
<level value="trace"/>
</logger>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 09, 2009 3:23 am 
Newbie

Joined: Tue Jun 24, 2008 6:55 am
Posts: 4
Location: Mumbai
That works ... Thanks

_________________
Sanchit Srivastava


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.