-->
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.  [ 4 posts ] 
Author Message
 Post subject: Dumb question - Hibernate debug logging
PostPosted: Tue Feb 06, 2007 10:25 am 
Newbie

Joined: Fri Jan 19, 2007 1:41 pm
Posts: 8
OK, I need a little help switching on debug logging in Hibernate running under JBoss.

I thought I would be able to switch it on by adding an appender and some categories to my log4j.xml file in JBoss. Here's what I added:

Code:
   <!-- ======================= -->
   <!-- Hibernate -->
   <!-- ======================= -->
   
   <appender name="HIBERNATE" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/hibernate.log"/>
      <param name="Append" value="false"/>

      <!-- Rollover at midnight each day -->
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>

      <!-- Rollover at the top of each hour
      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
      -->

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] Message\n -->
         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
          -->
      </layout>
   </appender>
   
   <category name="org.hibernate">
     <priority value="DEBUG" />
     <appender-ref ref="HIBERNATE"/>
   </category>
   <category name="org.hibernate.SQL">
     <priority value="DEBUG" />
     <appender-ref ref="HIBERNATE"/>
   </category>
   <category name="org.hibernate.type">
     <priority value="DEBUG" />
     <appender-ref ref="HIBERNATE"/>
   </category>


I expected to see debug messages streaming to my hibernate.log file, but no such luck. In fact I get nothing at all.

This seems overly complex, is there a simple way of getting the debug messages out of Hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 12:36 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Have you added your HIBERNATE appender to the root logger?

Code:
<root>
      <appender-ref ref="CONSOLE"/>
      <appender-ref ref="FILE"/>
      <appender-ref red="HIBERNATE"/>
</root>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 2:51 pm 
Newbie

Joined: Fri Jan 19, 2007 1:41 pm
Posts: 8
thanks for the reply. That certainly helped, but now I get everything in my hibernate.log file including the full contnts of the server.log.

Downside is that I still don't get debug messages from Hibernate, just INFO. I'm inching closer.

I'm surprised there isn't a logging config setting somewhere simple like my hibernate.cfg.xml...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 12:57 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
The reason you are seeing all the server logs is because the hibernate appender is added to the root logger. I take my comment back.

That you have should work it seems like.

I tried a similar thing and it does work.

If you are still not seeing anything try changing DEBUG to ALL. And try with just org.hibernate category to start with. The extra two categories you have will not make a difference. Once you have org.hibernate set to DEBUG, anything deeper that that (org.hibernate.*) should be set to DEBUG as well.

Budyanto


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.