问题描述
我正在使用Hibernate,并且正在尝试记录Hibernate会自动生成控制台的所有SQL,以便我可以查看映射中是否存在错误.我正在使用log4j,所以我正在尝试使用
log4j.logger.org.hibernate.SQL=ALL, SQL_APPENDER
显示Hibernate使用的所有SQL,但这不起作用.我已经将此代码添加到我的log4j.properties文件中,但它不起作用!我忘记了什么还是做错了什么
我想显示这样的东西
Hibernate: INSERT INTO mkyong.stock_transaction (CHANGE, CLOSE, DATE, OPEN, STOCK_ID, VOLUME) VALUES (?, ?, ?, ?, ?, ?)
推荐答案
我设法解决了这个问题.而不是使用
log4j.logger.org.hibernate.SQL=ALL, SQL_APPENDER
在我的log4j.properties文件中应该是
log4j.category.org.hibernate.SQL = ALL
问题描述
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 (?, ?, ?, ?, ?, ?)
推荐答案
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