If you're using clojure.tools.logging with SLF4J.
It's often useful to 'switch on' logging for a given web request, or during the evaluation of a given form, etc.
Add this to your logback.xml configuration:
<turboFilter class="ch.qos.logback.classic.turbo.MDCFilter">
<MDCKey>logging</MDCKey>
<Value>on</Value>
<OnMatch>ACCEPT</OnMatch>
</turboFilter>
Add the following Clojure macro:
(defmacro with-logging [& body]
`(try
(org.slf4j.MDC/put "logging" "on")
~@body
(finally
(org.slf4j.MDC/remove "logging"))))
Now you can do this:
(with-logging
(log/trace "hello"))
This allows you to turn down logging (e.g. to INFO), but be able to log tracing messages for a particular context.