-
-
Notifications
You must be signed in to change notification settings - Fork 173
4 Interop
tools.logging can use Timbre as its logging implementation (backend). This'll let tools.logging calls trigger Timbre logging calls.
To do this:
- Ensure that you have the tools.logging dependency, and
- Require the
taoensso.timbre.tools.logging
namespace - Call
taoensso.timbre.tools.logging/use-timbre
SLF4Jv2 can use Timbre as its logging backend. This'll let SLF4J logging calls trigger Timbre logging calls.
To do this:
- Ensure that you have the SLF4J dependency ( v2+ only), and
- Ensure that you have the Timbre SLF4J backend dependency
When com.taoensso/timbre-slf4j
(2) is on your classpath AND no other SLF4J backends are, SLF4J will automatically direct all its logging calls to Timbre.
If you want to have more control, you can set the slf4j.provider
Java system property to the Timbre SLF4J service provider: -Dslf4j.provider=com.taoensso.timbre.slf4j.TimbreServiceProvider
If you want to debug which provider is being used, you can enable SLF4J internal debug messages via the slf4j.internal.verbosity
Java system property: -Dslf4j.internal.verbosity=DEBUG
If you do not see log messages from code that should use SLF4J (e.g. the OpenTelemetry Java agent configured with the otel.javaagent.logging
Java system property), or the log messages are not processed by Timbre (e.g. the output format differs), then you might need to call (org.slf4j.LoggerFactory/getLogger (str *ns*))
right after application start (i.e. at the beginning of your -main
Clojure function) to initialize SLF4J.
Timbre needs SLF4J API version 2 or newer. If you're seeing
Failed to load class "org.slf4j.impl.StaticLoggerBinder"
it could be that your project is importing the older v1 API, check withlein deps :tree
or equivalent.
For other (non-SLF4J) logging like Log4j, java.util.logging (JUL), and Apache Commons Logging (JCL), use an appropriate SLF4J bridge and the normal SLF4J config as above.
In this case logging will be forwarded:
- From Log4j/JUL/JCL/etc. to SLF4J, and
- From SLF4J to Timbre