twitter-api icon indicating copy to clipboard operation
twitter-api copied to clipboard

SLF4J dependency error

Open andreventer-ai opened this issue 8 years ago • 7 comments

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

andreventer-ai avatar Oct 18 '16 12:10 andreventer-ai

Hi @MaxBittker what do you mean by "get this running"? Those SLF4J lines are just warnings that the logging apparatus that http.async.client depends on isn't set up, so it's not going to log anything low-level about the underlying HTTP connection / requests / responses, but otherwise it runs just fine.

The documentation for clojure's tools.logging (and on GitHub) leaves a lot to be desired, but if you really want to dig in and get all the HTTP logs, I found Googling "project.clj logging clojure" a good place to start, particularly:

  • http://www.bahmanm.com/blogs/how-to-add-logging-to-a-clojure-project
  • https://spin.atomicobject.com/2015/05/11/clojure-logging/

(P.S. This was in response to a subsequently-deleted comment: "Does anyone know how to get this running now? new to jvm ecosystem")

chbrown avatar Feb 11 '17 06:02 chbrown

hey chbrown, I actually was making a silly syntax mistake setting up hello world with this library and the warning just threw me off. thanks for your response!

MaxBittker avatar Feb 11 '17 07:02 MaxBittker

Hello, thank you for the library. I have a similar issue - after I get these warnings, none of my existing clojure.tools.logging calls actually do anything - using the twitter-api works but seems to have broken my ability to log anything. Is this linked to SLF4J? thank you,

alex314159 avatar Jun 11 '18 20:06 alex314159

Hi @alex314159, if you run lein deps :tree in this root of this repository, you'll see this output:

 [clj-oauth "1.5.5"]
   [clj-http "2.0.1"]
     [commons-io "2.4" :exclusions [[org.clojure/clojure]]]
     [org.apache.httpcomponents/httpclient "4.5" :exclusions [[org.clojure/clojure]]]
       [commons-logging "1.2"]
     [org.apache.httpcomponents/httpcore "4.4.1" :exclusions [[org.clojure/clojure]]]
     [org.apache.httpcomponents/httpmime "4.5" :exclusions [[org.clojure/clojure]]]
     [potemkin "0.4.1" :exclusions [[org.clojure/clojure]]]
       [clj-tuple "0.2.2"]
       [riddley "0.1.10"]
     [slingshot "0.12.2" :exclusions [[org.clojure/clojure]]]
   [commons-codec "1.8"]
   [org.bouncycastle/bcpkix-jdk15on "1.54"]
   [org.bouncycastle/bcprov-jdk15on "1.54"]
 [http.async.client "1.2.0"]
   [com.ning/async-http-client "1.9.39"]
     [io.netty/netty "3.10.5.Final"]
     [org.slf4j/slf4j-api "1.7.12"]
   [org.clojure/tools.logging "0.3.1"]
 [org.clojure/clojure "1.8.0"]
 [org.clojure/data.codec "0.1.0"]
 [org.clojure/data.json "0.2.6"]

twitter-api itself doesn't pull in any logging facilities, so if you're up against some sort of library conflict, it might be due to http.async.client's direct dependency on [org.clojure/tools.logging "0.3.1"] or its transitive dependency on org.slf4j/slf4j-api.

I can't replicate your precise issue without more details, but you might try adding a dependency on the latest http.async.client version and replacing your [twitter-api "1.8.0"] dependency with [twitter-api "1.8.0" :exclusions [http.async.client]].

LMK if that works and I'll see about updating the dependency in twitter-api.

chbrown avatar Jun 11 '18 21:06 chbrown

thanks let me try. FWIW I tried your twttr repo too which doesn't use http.async.client - no SLF4J warning, and I get all my logs but in the repl instead of them being written to a log file - so maybe not just a http.async.client issue. I'll try and create a dummy app to isolate the problem.

alex314159 avatar Jun 11 '18 21:06 alex314159

Yeah, I've been learning a lot about Java logging best practices lately, and your original comment reminded me to cut a new twttr release with my recent change that moved the logback-classic dependency into the :dev profile so that it doesn't constrain whatever logging backend the end-user (you) might happen to be using. So you might try the new [twttr "3.2.0"] — fresh off the press!

chbrown avatar Jun 11 '18 21:06 chbrown

Chris, you're a star! The new twttr 3.2.0 is working fine with all my logs working as expected! A big thank you!!!

alex314159 avatar Jun 11 '18 21:06 alex314159