Logging hibernate SQL using log4j

[亡魂溺海] 提交于 2019-12-08 06:46:25

问题


I am using hibernate and I am trying to log all the SQL that hibernate automatically generates to the console so that i can see if there is an error in my mapping. I am using log4j so i am trying to use

log4j.logger.org.hibernate.SQL=ALL, SQL_APPENDER

to display all the SQL that hibernate is using but this is not working. I have added this line of code to my log4j.properties file but it is not working! am i forgetting something or doing something wrong

i want to display something like this

Hibernate: INSERT INTO mkyong.stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME) 
VALUES (?, ?, ?, ?, ?, ?)

回答1:


I managed to solve this. Instead of using

log4j.logger.org.hibernate.SQL=ALL, SQL_APPENDER

in my log4j.properties file it should be

log4j.category.org.hibernate.SQL = ALL


来源:https://stackoverflow.com/questions/11264288/logging-hibernate-sql-using-log4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!