使用log4j记录休眠SQL [英] Logging hibernate SQL using log4j

查看:68
本文介绍了使用log4j记录休眠SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用休眠模式,并且试图将休眠模式自动生成的所有SQL记录到控制台,以便我可以查看映射中是否存在错误.我正在使用log4j,所以我尝试使用

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

以显示休眠中正在使用的所有SQL,但这不起作用.我已经将这行代码添加到我的log4j.properties文件中,但是它不起作用!我是在忘记某件事还是做错了什么

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

我想显示这样的东西

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

在我的log4j.properties文件中应该是

log4j.category.org.hibernate.SQL = ALL

这篇关于使用log4j记录休眠SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆