hibernate 日志

Hibernate 使用 Simple Logging Facade for Java (SLF4J) 去记录各个系统事件。SLF4J 可以基于你选择的捆绑将你的日志输出到一些日志框架。

为了设置日志记录,你需要slf4j-api.jar在你的classpath下。在使用log4j的情况下必须有slf4j-log4j12.jar.为了使用log4j必须在classpath

下创建一个log4j.properties文件举例来说这个配置文件在 src/目录下。

建议你熟悉一下hibernate的日志消息。很多工作被投入到hibernate日志中以便使他更为详细。最有趣的日志分类有以下几种:

Category Function
org.hibernate.SQLLog all SQL DML statements as they are executed
org.hibernate.typeLog all JDBC parameters
org.hibernate.tool.hbm2ddlLog all SQL DDL statements as they are executed
org.hibernate.prettyLog the state of all entities (max 20 entities) associated with the session at flush time
org.hibernate.cacheLog all second-level cache activity
org.hibernate.transactionLog transaction related activity
org.hibernate.jdbcLog all JDBC resource acquisition
org.hibernate.hql.internal.ast.ASTLog HQL and SQL ASTs during query parsing
org.hibernate.secureLog all JAAS authorization requests
org.hibernateLog everything. This is a lot of information but it is useful for troubleshooting

在开发hibernate应用时,在debug 中 org.hibernate.SQL总是被使用的,或者选择性使用

 hibernate.show_sql 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值