hibernate4.1.8使用JBoss Logging
什么是slf4j?
slf4j是Simple Logging Facade for Java的简称。
以下这段是Hibernate4.1.8官方文档中关于日志的:
Simple Logging Facade for Java (SLF4J) in order to log various system events.
SLF4J can direct your logging output to several logging frameworks
(NOP, Simple, log4j version 1.2, JDK 1.4 logging, JCL or logback) depending on your chosen binding.
In order to setup logging you will need slf4j-api.jar in your classpath together with the jar file for your preferred binding
- slf4j-log4j12.jar in the case of Log4J. See the SLF4J documentation for more detail.
To use Log4j you will also need to place a log4j.properties file in your classpath.
An example properties file is distributed with Hibernate in the src/ directory.
以上这段话大概的意思是: 什么是sjf4j,以及依赖的jar及配置
slf4j与log4j的关系:slf4j像是一个大管家,可以管理许多的日志框架,log4j是其中之一a) 首先加入slf4j的jar包,slf4j-api-1.7.1.jar, 这个里面全中接口。
b) 加入log4j-1.2.17.jar,即slf4j的log4j实现。
c) slf4j怎么将日志转成log4j? 加入slf4j-log4j12-1.7.1.jar 转换包
c) 从hibernate/project/etc 目录 copy log4j.properties配置文件
d) 査询hibernate文裆,配置其输出策略,主要是两个属性: show_sql、format_sql