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: trueHowever, 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