logback slf4j

项目使用spring + hibernate 因为现在接触到部分项目已经开始使用logback,所以想在现有的项目中使用logback

hibernate 本身采用的是slf4j所以直接把项目中导入logback就可以打印出hibernate日志

但是spring-core还是依赖commons-logging所以需要jcl-over-slf4j转到slf4j

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>jcl-over-slf4j</artifactId>
	<version>1.6.4</version>
</dependency>       

      

目前在github已有针对spring的扩展包使用

https://github.com/qos-ch/logback-extensions

<dependency>
<groupId>org.logback-extensions</groupId>
<artifactId>logback-ext-spring</artifactId>
<version>0.1.1</version>
</dependency>

但是官网上对此包是在spring 3.1.1版本上通过编译的,要求版本最好是在spring 3.1.1之后

经试验 在spring 3.1.0版本上也是可行的,其它版本未验证

在此特作记录

猜你喜欢

转载自zyz251314.iteye.com/blog/1849138