This post is to show how you can weak small settings for log4j to enable the logging rather in a application log file than System.out. Also included is nifty tip to get the values which were assigned to the the prepared statements that hibernate would have used for retrieval of data from database.
[PS: This is nothing new. I am just posting here so that I can remember and may be some other guys would benefit from it]
- Basic SQL debugging on and off
- Moving your SQL queries to Log a file using log4j configuration. Just add following lines into you log4j.properties.
- Logging the parameters passed to the Prepared statement to log file using log4.properties file setting.
<property name="show_sql">true</property>
# setup for HQL to log
log4j.logger.net.sf.hibernate.SQL=DEBUG, consoleName
log4j.additivity.org.hibernate.SQL=false
# to read the values attached to Prepared statments of Hibernate
log4j.logger.net.sf.hibernate.type=DEBUG, consoleName
net.sf.hibernate with org.hibernate in above log4j.properties file settingsThat's all for now!
Regards,
Vijay Dharap
