sql_show = true
this property in hibernate prints the sql that is run, but i want to see the begin transaction
and complete transaction
statements as well so that i can track the transaction duration and see the query run in which transaction.
googling reveals that
log4j.logger.org.hibernate.SQL = DEBUG, defaultAppender
log4j.logger.org.hibernate.type = DEBUG, defaultAppender
log4j.logger.org.hibernate.transaction=DEBUG, defaultAppender
should show you the transaction level data as well. But it doesnt.
Investigating more i looked into hibernate code and found a class name
org.hibernate.ejb.TransactionImpl
this class has the begin and complete method but this method does not log any thing.
Any advice how to see the transaction level info in hibernate ?
I am using hibernate 2.2
The better way to activate the logging of executed SQL statements is to set the log level of the org. hibernate. SQL category to DEBUG (or the corresponding log level of your log framework).
Hibernate utilizes Simple Logging Facade for Java (SLF4J) in order to log various system events. SLF4J can direct your logging output to several logging frameworks (NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your chosen binding.
For SLF4J logging:
<logger name="org.hibernate.engine.transaction.internal.TransactionImpl" level="debug"/>
For Log4j:
<logger name="org.hibernate.engine.transaction.internal.TransactionImpl">
<level value="DEBUG"/>
</logger>
You need to set the logging threshold to DEBUG for the following classes:
For JDBC transactions (e.g. RESOURCE_LOCAL)
For SLF4J logging:
<logger name="org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction" level="debug"/>
For Log4j:
<logger name="org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction">
<level value="DEBUG"/>
</logger>
For JTA transactions
For SLF4J logging:
<logger name="org.hibernate.engine.transaction.internal.jta.JtaTransaction" level="debug"/>
For Log4j:
<logger name="org.hibernate.engine.transaction.internal.jta.JtaTransaction">
<level value="DEBUG"/>
</logger>
It's better to activate the DEBUG level for as few classes as possible because otherwise, your logs size will increase dramatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With