Debugging “Hibernate bind parameters not getting logged”

I did set org.hibernate.type=trace. But it still didn’t print bind parameters. So decided to debug through the hibernate source code.  The code for logging the bind parameters exists in org.hibernate.type.NullableType.nullSafeSet(PreparedStatement, Object, int). Found that it is infact logging the bind parameters. But I still don’t see those in the log file or the console. I might have to dig deeper into the org.slf4j.Logger.trace method.

The issue turned out to be with the appender and the appender threshold. We have 3 appenders in our log4j configuration and we were using only one of the the 3 for the category “org.hibernate.type”. And this appender had threshold set WARN, as a result it kept supressing all the “trace” logs. Another thing you need to be careful about this is that you need to initialize log4j before calling hibernate API. This is because hibernate determines the log level at class load time using the following statement:
private static final boolean IS_VALUE_TRACING_ENABLED = LoggerFactory.getLogger( StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled();


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: