Hibernate Log

本文介绍Hibernate日志机制及其限制,特别是在SQL参数记录方面的不足。为解决这一问题,推荐使用JDBC代理驱动来实现更精细的日志记录,包括在同一行中记录SQL语句及其参数,并提供执行时间和调用代码行的跟踪。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Hibernate cannot log the SQL and its parameters in the same line like you want . The logging provided by the Hibernate (by setting log4j.logger.org.hibernate.SQL=debug and log4j.logger.org.hibernate.type=trace in the log4j configuration) can only log the SQL and the parameters in the different lines likes this :

insert 
intoAddress(address1, address2, city, province) 
values
    (?,?,?,?)
binding parameter [1]as[VARCHAR]- xxxxxx
binding parameter [2]as[VARCHAR]- xxxxxx
binding parameter [3]as[VARCHAR]- xxxx

You have to use JDBC proxy driver if you want to log the SQL with the parameters in the same line. I have tried log4jdbc and it can do it ,and it also can log the time spent by every SQL statement and log the lines in the code that cause the SQL statements .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值