I received a project done by another developer (whom I cannot get in touch with right now). In that project, slf4j is used for logging. But I see log4j-1.2.17.jar along with logback-access-1.0.9.jar,logback-classic-1.0.9.jar,logback-core-1.0.9.jar in the classpath. Also both log4j.properties
and logback.xml
files are in the resources. Now I am confused which implementation is actually used. Can anyone suggest anything?
Update
There is also slf4j-api-1.7.2.jar and slf4j-log4j12-1.7.2.jar in classpath
-
I believe for log4j to work you need the log4j bridge (slf4j.org/legacy.html). Is the bridge also present? (Note: I could be wrong about this, I only ever used logback with slf4j) In the end, does it matter? If both configurations do approximately the same thing you should be able to simply remove the log4j as it will definitely use logback then.nablex– nablex03/03/2015 07:08:00Commented Mar 3, 2015 at 7:08
1 Answer 1
If you don't see slf4j-api.jar
in the class path then, as mentioned below, SLF4J will default to a no-operation implementation. It seems like the other developer was using SLF4J to plug in log4j-1.2.17.jar
(log4j) along with logback-access-1.0.9.jar
, logback-classic-1.0.9.jar
and logback-core-1.0.9.jar
(logback) at deployment time.
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (
e.g. java.util.logging
,logback
,log4j
) allowing the end user to plug in the desired logging framework at deployment time.Before you start using SLF4J, we highly recommend that you read the two-page SLF4J user manual.
Note that SLF4J-enabling your library implies the addition of only a single mandatory dependency, namely
slf4j-api.jar
. If no binding is found on the class path, then SLF4J will default to a no-operation implementation.