[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2835?page=c...
]
bartleby42 commented on HHH-2835:
---------------------------------
When debugging org.hibernate.type.NullableType, I found the level of the logger
"org.hibernate.type" was always INFO, cached or uncached, and regardless of the
log4j configuration. It seems the level is altered programmatically somewhere after
configuration.
My (experimental) workaround is to alter it back again according to the configuration of a
helper logger. This can be accomplished without replacing or patching any libraries
involved. Unfortunately, the code depends on log4j and org.apache.commons.logging.impl,
which may not be a problem in temporary debugging code:
(1) The snippet to copy the level:
Log workaroundLog = LogFactory.getLog("org.hibernate.type.workaround");
Log typeLog = LogFactory.getLog("org.hibernate.type");
if (workaroundLog instanceof org.apache.commons.logging.impl.Log4JLogger
&& typeLog instanceof org.apache.commons.logging.impl.Log4JLogger){
org.apache.log4j.Logger log4jWorkaroundLogger =
(org.apache.log4j.Logger)((org.apache.commons.logging.impl.Log4JLogger)workaroundLog)
.getLogger();
org.apache.log4j.Logger log4jTypeLogger =
(org.apache.log4j.Logger)((org.apache.commons.logging.impl.Log4JLogger)typeLog)
.getLogger();
log4jTypeLogger.setLevel(log4jWorkaroundLogger.getLevel());
}
(2) Place this code after log4j is configured, but before the class
org.hibernate.type.NullableType is loaded. In our Tomcat and Spring environment, it was
sufficient to make the LocalSessionFactoryBean depend on a helper bean with the above code
in its constructor:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
depends-on="hibernate-type-logging-workaround">
(3) Configure the logger "org.hibernate.type.workaround" instead of
"org.hibernate.type"
Setting org.hibernate.type logging to debug produces no logging
---------------------------------------------------------------
Key: HHH-2835
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2835
Project: Hibernate3
Issue Type: Bug
Components: core, documentation
Affects Versions: 3.2.4, 3.2.5
Environment: Hibernate 3.2.4.ga and Hibernate 3.2.5.ga with MySQL5Dialect
(configured with Hibernate Annotations 3.3.0.ga and Spring 2.0.6)
Reporter: Jeremy Grodberg
Assignee: Diego Plentz
Priority: Minor
According to the online documentation (labeled as version 3.2.2 at this moment), Table
3.9 "Hibernate Log Categories", as viewed here today:
http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configurat...
Setting the log4j category "org.hibernate.type" to debug should "Log all
JDBC parameters". However, it produces no output at all.
When I go on to set "org.hibernate" to debug, I get output like this:
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open
PreparedStatements: 0, globally: 0)
DEBUG: org.hibernate.SQL - select count(*) from album where genreID=?
DEBUG: org.hibernate.loader.Loader - bindNamedParameters() 126 -> genreId [1]
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0,
globally: 0)
DEBUG: org.hibernate.loader.Loader - result row:
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1,
globally: 1)
DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open
PreparedStatements: 1, globally: 1)
Note that the JDBC parameters are logged under org.hibernate.loader but nothing appears
under org.hibernate.type. FYI, genreId is, in this case, a Long.
Perhaps this is expected/desired when using annotations? If so, then please update the
documentation. If not, please restore the logging.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira