hibernate 打印sql和参数的配置

1、配置spring-hiberbate.xml:
<prop key="hibernate.show_sql">true</prop>--强制打印sql 不受log4j影响
<prop key="hibernate.format_sql">true</prop>--格式化sql
<prop key="hibernate.use_sql_comments">true</prop>--添加sql的注释,说明sql的触发来源
2、配置log4j:添加log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
log4j配置sql绑定的参数日志级别 trace比debug低

示例:

log4j.rootLogger=ERROR,A1,R
log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=TRACE log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.Target=System.out
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=[%c]%m%n
上一篇:从源码层面理解 ArrayList 扩容策略


下一篇:linux下面的打包压缩命令