Logging

By default, logging functionality is provided by the timbre library. This is used together with the slf4j-timbre and slf4j-api helpers that manages logging from components using slf4j logging.

Any Clojure data structures can be logged directly.

Examples

(ns example
 (:require [taoensso.timbre :as log]))

(log/info "Hello")
=>[2015-12-24 09:04:25,711][INFO][myapp.handler] Hello

(log/debug {:user {:id "Anonymous"}})
=>[2015-12-24 09:04:25,711][DEBUG][myapp.handler] {:user {:id "Anonymous"}}

Configuring logging

Each profile has its own log configuration found under the env/*/resources/taoensso.timbre.config.edn. For example, this is what the dev logging config looks like:

{:min-level [[#{"io.methvin.watcher.*"} :info]
             [#{"datahike.*"} :info]
             [#{"org.eclipse.jetty.*"} :warn]
             [#{"jobtech-taxonomy-api.db.database-connection"} :warn]
             [#{"jobtech-taxonomy.features.mapping.*"} :info]
             [#{"*"} :debug]]}

There is also a common configuration that is not specific to any profile found at resources/taoensso.timbre.config.edn:

{:min-level [[#{"*"} :info]]}

Logging of exceptions

(ns example
 (:require [taoensso.timbre :as log]))

(log/error (Exception. "I'm an error") "something bad happened")
=>[2015-12-24 09:43:47,193][ERROR][myapp.handler] something bad happened
  java.lang.Exception: I'm an error
    at myapp.handler$init.invoke(handler.clj:21)
    at myapp.core$start_http_server.invoke(core.clj:44)
    at myapp.core$start_app.invoke(core.clj:61)
    ...