-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem setting log level TRACE in org.hibernate.tye package
PostPosted: Wed Feb 20, 2008 11:00 am 
Newbie

Joined: Tue Feb 19, 2008 6:48 am
Posts: 17
Hibernate version:
3.2.6

Commons-logging version:
1.1.1

Log4j version:
1.2.15

log.properties file:

Code:
log4j.rootLogger=INFO, console
log4j.logger.org.hibernate.SQL = TRACE
log4j.logger.org.hibernate.type = TRACE

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=IPDMS[%d{yyyy-MM-dd HH:mm:ss}] %5p (%F:%L) %m%n


I'm trying to log the prepared statement parameters of a insert query (that is generating a constraint violation exception). I was using a spring log4j initialization listener (org.springframework.web.util.Log4jConfigListener), but i created my one:

Code:
package com.test;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
import org.hibernate.type.Type;
import org.hibernate.util.StringHelper;

public class LogListener implements ServletContextListener {

   public void contextInitialized(ServletContextEvent arg0) {
      try {
         PropertyConfigurator.configure(arg0.getServletContext().getRealPath("WEB-INF/classes/conf/log.properties"));
         Log log = LogFactory.getLog( StringHelper.qualifier( Type.class.getName() ) );
         System.out.println("Is trace enable for Type: " + log.isTraceEnabled());
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   public void contextDestroyed(ServletContextEvent arg0) {
   }
}


I add this listener to my web.xml file, and when i start my web application it prints:
Is trace enable for Type: true

However, in org.hibernate.type.NullableType, the static final IS_TRACE_ENABLED, that is initialized as:

Code:
   private static final boolean IS_TRACE_ENABLED;
   static {
      //cache this, because it was a significant performance cost; is
      // trace logging enabled on the type package...
      IS_TRACE_ENABLED = LogFactory.getLog( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled();
   }


(same as my listener class), the value is FALSE! And because of this, i'm not able to debug my insert sql.

Can someone explain to me why the value IS_TRACE_ENABLED is false instead of TRUE?

Thanks

_________________
João Simas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 21, 2008 7:08 am 
Newbie

Joined: Tue Feb 19, 2008 6:48 am
Posts: 17
'm a very idiot, very idiot man!

The problem of logging was the order of the Listeners in my web.xml file. SpringContext (where i define Hibernate Connection) was first than my Log listener....

Problem solved.

_________________
João Simas


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