简体   繁体   English

将SLF4J与Log4J混合

[英]Mix SLF4J with Log4J

I've got a logger implementing the SLF4J interface and a class org.slf4j.impl.StaticLoggerBinder implementing org.slf4j.spi.LoggerFactoryBinder on the classpath, because it is in the same jar as other required dependencies. 我有一个实现SLF4J接口的记录器,以及一个在类路径上实现org.slf4j.spi.LoggerFactoryBinder的类org.slf4j.impl.StaticLoggerBinder ,因为它与其他所需依赖项位于同一个jar中。

Now I want to use the Log4J-Logger in a project using the Log4J interface only, but relying on other libs which use SLF4J. 现在,我只想在使用Log4J接口的项目中使用Log4J-Logger,但要依赖使用SLF4J的其他库。 Therefore I will have to throw a SLF4J-LOG4J-Bridge into the classpath. 因此,我将不得不将SLF4J-LOG4J-Bridge扔到类路径中。

I'm wondering if my org.slf4j.impl.StaticLoggerBinder will interfere with the SLF4J-LOG4J-Bridge . 我想知道org.slf4j.impl.StaticLoggerBinder是否会干扰SLF4J-LOG4J-Bridge Must I remove my org.slf4j.impl.StaticLoggerBinder to get the LOG4J-Logger working. 我必须删除我的org.slf4j.impl.StaticLoggerBinder才能使LOG4J-Logger工作。 Or asked differently: Does the SLF4J-LOG4J-Bridge also implement org.slf4j.impl.StaticLoggerBinder ? 还是不同地问: SLF4J-LOG4J-Bridge是否也实现org.slf4j.impl.StaticLoggerBinder

org.slf4j.impl.StaticLoggerBinder is an class and not an interface. org.slf4j.impl.StaticLoggerBinder是一个类,而不是一个接口。

If you go to http://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12/1.6.4 , download and open the jar you will see that it doesn't contain StaticLoggerBinder class. 如果您转到http://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12/1.6.4 ,下载并打开jar,您将看到它不包含StaticLoggerBinder类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM