We can use two ways of hibernate configuration for debugging the sql queries generated by hibernate framework.
1. Using log4j.properties
# Hibernate logging options (INFO only shows startup messages)
Log4j.logger.org.hiernate=INFO
Log4j.rootLogger=INFO, console
#The below logger statement is equivalent to hibernate.show_sql=true
log4j.logger.org.hibernate.SQL = DEBUG
# Log JDBC bind parameter runtime arguments.
# The below logger prints the values binded to sql query and the response from the query.
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
2. Hibernate configuration
1. Using log4j.properties
# Hibernate logging options (INFO only shows startup messages)
Log4j.logger.org.hiernate=INFO
Log4j.rootLogger=INFO, console
#The below logger statement is equivalent to hibernate.show_sql=true
log4j.logger.org.hibernate.SQL = DEBUG
# Log JDBC bind parameter runtime arguments.
# The below logger prints the values binded to sql query and the response from the query.
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
2. Hibernate configuration
<property name="show_sql">true</property> <property name="format_sql">true</property> <property name="use_sql_comments">true</property>
No comments:
Post a Comment