Note that SLF4J-enabling your library implies the addition of only a single mandatory dependency, namely slf4j-api.jar. If no binding/provider is found on the class path, then SLF4J will default to a no-operation implementation.
It very much looks like the version of slf4j-api.jar being loaded by the JVM has version 1.5.x. You surely have slf4j-api-1.5.x.jar on your class path (in addition to slf4j-api-1.6.2.jar). Check your class path.
Mixing different versions of slf4j-api.jar and SLF4J binding can cause problems. For example, if you are using slf4j-api-1.7.2.jar, then you should also use slf4j-simple-1.7.2.jar, using slf4j-simple-1.5.5.jar will not work.
NOTE From the client's perspective all versions of slf4j-api are compatible. Client code compiled with slf4j-api-N.jar will run perfectly fine with slf4j-api-M.jar for any N and M. You only need to ensure that the version of your binding matches that of the slf4j-api.jar. You do not have to worry about the version of slf4j-api.jar used by a given dependency in your project. You can always use any version of slf4j-api.jar, and as long as the version of slf4j-api.jar and its binding match, you should be fine.
Also, you must have a many slf4j-api jars of versions mentioned in the []. Try keeping a single version of slf4j-api and the corresponding compatible slf4j-log4j jars in the classpath.
This may be more "me too", but I'll try to outline a more complete solution. I mix a lot of software from diverse sources together in my product. I encountered this problem first with NiFi JARs, then more recently with Cassandra JARs all over again. I had already insisted in pom.xml that I have the same version of slf4j everywhere:
From mvn dependency:tree, I found out that I was getting logback 1.1.3 which wasn't matching what Cassandra was apparently using (0.9-something like you). So, I excluded getting logback too by adding these exclusions to slf4j ones already there:
An SLF4J binding designates an artifact such as slf4j-jdk14.jar or slf4j-log4j12.jar used to bind slf4j to an underlying logging framework, say, java.util.logging or log4j. Mixing mixing different versions of slf4j-api.jar and SLF4J binding can cause problems. For example, if you are using slf4j-api-1.6.6.jar, then you should also use slf4j-simple-1.6.6.jar, using slf4j-simple-1.5.5.jar will not work.
NOTE From the client's perspective all versions of slf4j-api are compatible. Client code compiled with slf4j-api-N.jar will run perfectly fine with slf4j-api-M.jar for any N and M. You only need to ensure that the version of your binding matches that of the slf4j-api.jar. You do not have to worry about the version of slf4j-api.jar used by a given dependendency in your project. You can always use ANY version of slf4j-api.jar, and as long as the version of slf4j-api.jar and its binding match, you should be fine.
Given that all versions of slf4j-api are interchangeable from the clients perspective, in the scenario where different versions of slf4j-api and its binding e.g. slf4j-log4j12 are pulled in, explicitly declare them as dependencies in your POM as follows:
I realised that one of my projects uses slf4j 1.5.8 and Hibernate uses slf4j 1.6. While building with Maven it downloads both jars but I guess the class files of 1.5.8 are used. So, when I run the program i get following error:
Planning for the advent of Jigsaw (Java 9), slf4j-api version 1.8.x and later use the ServiceLoader mechanism. Earlier versions of SLF4J relied on the static binder mechanism which is no longer honored by slf4j-api.
Also, have you seen spf4j-slf4j-test? This looks like what you are looking for. The latest version does not yet support slf4j 1.8 but the project seems to be actively maintained.
Support for Slf4j 1.8 may be added in a near future?
BUT, I also have an slf4j log message in that method, and it doesn't send anything out to the log console. I've tried for a few hours this evening, to try and get this to work, but with no luck. Without (at this stage) getting into my posting lots of config files, etc, can anybody point me to an idiots guide that spells out how to get slf4j log messages out of my web app?
I tried adding slf4j to my pom file, included it as a manifest dependency in the war plugin, added jboss-deploymentment-structure files to META-INF (which doesn't feel correct) to exlude default logging modules, and set the 'add-logging-api-dependencies' to false in the wildfly cli gui. Nothing seems to show the faintest hope of working.
What I hadn't stated originally was that my 'simple' project was copied from somewhere else. That project had a lot of dependencies (despite there not being much code in it), and buried away inside an 'uber' jar (created with the maven shade plugin - I told you a lot of this was new to me!) were the slf4j classes.
So what appears to have stopped slf4j working was the duplicate inclusion of slf4j libraries in my deployment. Minus that, just referencing the slf4j API in my POM would otherwise appear to be enough to get the logging 'working'.
I say 'appears', but I haven't yet tried this out on the original project. But I'm confident that you've helped me isolate the problem. I'll have to see if I can get slf4j excluded from that 'uber' jar, as I think I'm still going to need it for my 'real' app.
It's possible that some of my other settings are combining to actually make this work (like specifying an org.slf4j dependency for the manifest entry in the maven war plugin), but this was the change that allowed me to actually see my log messages on the console. I may go back and investigate further, but for now I'm exhausted by this and taking a break.
Things to look at if that isn't working is check your deployment for a log4j.xml or a log4j.properties file. Make sure you don't have another slf4j binding implementation packaged in your deployment. Other than that it should work fine.
James R. Perkins reply is only an acceptable answer if you want to accept JBoss's implementation below slf4j, and don't have any opinion on logging, and are willing to accept JBoss defaults. Which includes only logging Strings, for example.
Using slf4j-api in code is normal, but you still want to control logging output. Using JBoss makes this hard. Fiddling with standalone config in CI env is also hard compared to adding an XML file to each EAR.
Well slf4j is a logging facade. It has no concept of appenders. WildFly supplies an slf4j binding which binds to the JBoss Log Manager. If you want to use your own log manager it's quite easy to just exclude the logging subsystem. You then just need to include an slf4j-api library and a binder in your deployment.
A more common choice amongst SLF4J users, which uses fewer step sand generates fewer dependencies, is to bind directly to Logback. This removes the extra binding step because Logback implements SLF4J directly, so you only need to depend on two libaries not four (jcl-over-slf4j and logback). If you do that you might also need to exclude the slf4j-api dependency from other external dependencies (not Spring), because you only want one version of that API on the classpath.
This warning message is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar , slf4j-log4j12.jar , slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.
Apache Tika include a lot of Apache and thirdparty libraries that have different approach to logging. Tika use slf4j-api as logging API and Apache Log4j 2.x as an implementation for modules that require it.
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at file:/home/gross/.gradle/caches/modules-2/files-2.1/org.jboss.slf4j/slf4j-jboss-logmanager/1.2.0.Final/baff8ae78011e6859e127a5cb6f16332a056fd93/slf4j-jboss-logmanager-1.2.0.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class
SLF4J: See for an explanation.
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console..
JBoss Logging (slf4j-jboss-logging/slf4j-jboss-logmanager) as of 2022-11-09 are still on slf4j-api 1.7.x, see -165. Currently you can try downgrading org.slf4j:slf4j-api version to 1.7.36 if you have to use Tika with JBoss Logging (e.g. if you use Quarkus or WildFly native logging).
By default Tika will bring slf4j-api via tika-core and some bridges like org.slf4j:jcl-over-slf4j and org.slf4j:jul-to-slf4j as opinionated default. Depending on your logging backend and preferred configuration you'll need different dependency exclusions and bridges/implementations.
In you have no preference about logging backend it's enough to add org.apache.logging.log4j:log4j-core, org.apache.logging.log4j:log4j-slf4j2-impl and org.apache.logging.log4j:log4j-1.2-api (or org.slf4j:log4j-over-slf4j) and exclude log4j:log4j, commons-logging:commons-logging, ch.qos.logback:logback-classic, ch.qos.logback:logback-core, ch.qos.reload4j:reload4j and org.slf4j:slf4j-reload4j.
As of main branch (and Tika 2.6.0) all Tika source use slf4j-api as a logging API with org.apache.logging.log4j:log4j-core:2.x as the backend for applications like tika-app / tika-eval-app / tika-server.
Complete documentation is found at the project lombok features page for lombok log annotations. Example: @Slf4j public class LogExample will generate: public class LogExample private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class); This annotation is valid for classes and enumerations.
See Also: