[英]using slf4j with log4j
I am having a problem with slf4j with log4j. 我在使用log4j的slf4j遇到问题。
I have a log4j.xml on development environment and it is set to DEBUG. 我在开发环境上有一个log4j.xml,它设置为DEBUG。
In my pom.xml I have the following: 在我的pom.xml中,我具有以下内容:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
When I run my code and I use Logger (SLF4J) and I check whether debug is enabled - I get false and if anyway I try to log.debug I don't see the result. 当我运行代码并使用Logger(SLF4J)时,我检查是否启用了调试-我得到了false,并且无论如何我尝试进行log.debug都看不到结果。
but, if in the same class I use Logger (apache log4j) everything works well as I expect. 但是,如果在同一个班级中我使用Logger(apache log4j),那么一切都会按我预期的那样良好。
I read many posts about the log4j and slf4j but I could not solve it. 我读了许多有关log4j和slf4j的帖子,但我无法解决。
Your help is appreciated. 感谢您的帮助。
Thanks 谢谢
Sorry, I found a hint and fixed the problem. 抱歉,我找到了提示并解决了问题。 I add to change the pom to: 我添加将pom更改为:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
The mistake was I used slf4j-simple instead of slf4j-log4j12. 错误是我使用slf4j-simple而不是slf4j-log4j12。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.