{:deps {gist-uwo/logbacku {:git/url "https://gist.github.com/uwo/e98b012c0d9b4bfb4d3464c2ac1e5efd"
:sha "6febe8063e7189f39c1bdeb11db2e4ade519bcb8"}}}
-
-
Save uwo/e98b012c0d9b4bfb4d3464c2ac1e5efd to your computer and use it in GitHub Desktop.
Refresh logback.xml from a Clojure REPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:paths ["."] | |
:deps {ch.qos.logback/logback-classic {:mvn/version "1.2.3"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logbacku | |
(:require [clojure.java.io :as io]) | |
(:import ch.qos.logback.classic.joran.JoranConfigurator | |
ch.qos.logback.classic.LoggerContext | |
org.slf4j.LoggerFactory)) | |
(defn reload-logback | |
"Load the given logback configuration file or reload the previously | |
loaded one if none is provided." | |
([] | |
(reload-logback (java.lang.System/getProperty "logback.configurationFile"))) | |
([filepath] | |
(let [context ^LoggerContext (LoggerFactory/getILoggerFactory) | |
configurator (JoranConfigurator.) | |
config (io/file filepath)] | |
(assert config) | |
(.reset context) | |
(.setContext configurator context) | |
(.doConfigure configurator config) | |
{::reloaded-path filepath}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment