Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Lein repl adds commons-logging causing a project slf4j log configuration to be ignored #690

Closed
hugoduncan opened this Issue · 4 comments

2 participants

@hugoduncan

When running lein-repl, reply is added to the project's classpath. reply depends on commons-logging through cd-client, clj-http and the apache http client. This causes problems in projects that use clojure.tools.logging with a logger other commons-logging, since commons-logging has the highest priority when clojure.tools.logging looks for java logging implementations. When the project is using slf4j for example, the project's logging configuration ends up being ignored.

In application code, the commons-logging dependency is less of an issue, since when using slf4j for example, a dependency on org.slf4j/jcl-over-slf4j can be added to the project.

@technomancy
Owner

Can clojure.tools.logging be explicitly configured to prefer a given backend as a workaround while we try to come up with a better solution?

@hugoduncan
(alter-var-root #'clojure.tools.logging/*logger-factory* 
  (constantly (clojure.tools.logging.slf4j/load-factory)))

might do the trick (untested), and would allow configuration of all calls going through clojure.tools.logging, but still gives no control over logging via the commons-logging interface in say clj-http. For that I think the org.slf4j/jcl-over-slf4j dependency would need to be added.

There are no doubt similar work arounds for log4j.

@hugoduncan

For tools.logging 0.2.1 and before, the above should be:

(binding [*ns* (the-ns 'clojure.tools.logging.slf4j)]
    (alter-var-root
     #'clojure.tools.logging/*logger-factory*
     (constantly (clojure.tools.logging.slf4j/load-factory))))

The logger specific namespaces were removed in tools.logging 0.2.2, so this would need adjusting for that version and later.

@technomancy
Owner

Looks like the reorg-repl branch fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.