You rebind dynamic vars with binding, so your use would look something like this:
(binding [*logger-factory* (log-impl/log4j-factory)] (do-stuff-with-the-logger-factory-rebound)) On Thu, Nov 17, 2011 at 5:17 PM, vitalyper <[email protected]> wrote: > clojure.tools.logging defines *logger-factory* and initializes it with > first logger implementation on the class path > > (def ^{:doc > "An instance satisfying the impl/LoggerFactory protocol. Used > internally to > obtain an impl/Logger. Defaults to the value returned from impl/ > find-factory." > :dynamic true} > *logger-factory* > (impl/find-factory)) > > In my own namespace I want to redefine *logger-factory* to log4j one. > Tried different variations (def, set!, etc) in 1.3.0 with no avail. > (ns my.foo > (:gen-class) > (:use > [clojure.tools.logging :only (*logger-factory* info debug)]) > (:require > [clojure.string :as s1] > [clojure.tools.logging.impl :as log-impl]) > ) > > (defn init-logging > "Force log4j factory for core tools logging" > [] > (def *logger-factory* (log-impl/log4j-factory))) > ; CompilerException java.lang.IllegalStateException: *logger-factory* > already refers to: #'clojure.tools.logging/*logger-factory* in > namespace: infrared.common > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
