Hibernate,Log4j和SLF4j [英] Hibernate,Log4j and SLF4j

查看:176
本文介绍了Hibernate,Log4j和SLF4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用log4j
,我想禁用hibernate info logging,所以这里是我尝试的,但它不起作用,我仍然看到hibernate info logging:

i am using log4j and i want to disable hibernate info logging, so here's what i tried, but it doesn't work and i still see the hibernate info logging:

1- log4j.properties

1- log4j.properties:

log4j.rootLogger=DEBUG, stdout, rootLog
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.rootLog=org.apache.log4j.RollingFileAppender
log4j.appender.rootLog.File=${user.home}/devlopmentLogs/mylog.log
log4j.appender.rootLog.MaxFileSize=10000KB
log4j.appender.rootLog.MaxBackupIndex=3
log4j.appender.rootLog.layout=org.apache.log4j.PatternLayout
log4j.appender.rootLog.layout.ConversionPattern=%p %t %c - %m%n


log4j.logger.org.hibernate=FATAL
log4j.logger.org.springframework=ERROR
log4j.logger.org.springframework.security=ERROR



<2-> Jars :

2- Jars:

<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-entitymanager</artifactId>
   <version>3.6.8.Final</version>
</dependency>


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

<!-- concrete Log4J Implementation for SLF4J API-->

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

请告诉我为什么我仍然看到hibernate info logging,以及如何关闭它?

please advise why i am still seeing the hibernate info logging, and how to turn it off ?

是否需要从其他hibernate依赖关系中排除 slf4j-api

and do i need to exclude the slf4j-api from other hibernate dependencies ?

推荐答案

发现上述配置是正确的,log4j的更改未发布到classpath中。

found out that above configuration is correct and the changes to log4j wasn't published to classpath.

这篇关于Hibernate,Log4j和SLF4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆