Logging 将clojure日志配置为输出到nRepl
我正在寻找一种配置Logging 将clojure日志配置为输出到nRepl,logging,clojure,Logging,Clojure,我正在寻找一种配置clojure.tools.logging以将消息输出到nRepl的方法。我只找到一些要输出到控制台的配置 默认情况下,控制台输出打印在*nrepl服务器*缓冲区。所以,如果将clojure.tools.logging配置为将输出打印到控制台,则可以在*nrepl server*缓冲区中看到它 我在苹果酒文档中找不到改变这一点的方法。但是我发现关于这个问题。有人提议这样做: 但在我的安装(苹果酒0.12.0,Clojure 1.8.0)中,它抱怨(.start(Thread.#
clojure.tools.logging
以将消息输出到nRepl的方法。我只找到一些要输出到控制台的配置 默认情况下,控制台输出打印在*nrepl服务器*缓冲区。所以,如果将clojure.tools.logging配置为将输出打印到控制台,则可以在*nrepl server*缓冲区中看到它
我在苹果酒文档中找不到改变这一点的方法。但是我发现关于这个问题。有人提议这样做:
但在我的安装(苹果酒0.12.0,Clojure 1.8.0)中,它抱怨(.start(Thread.#)(println“Hello from a new Thread.”)
:
但是,如果我不运行(alter var root#'*out*(fn[#]*out*)
,那么打印下面的示例效果良好,并将其输出打印到*cider repl*,而不会出现错误或警告。记录器输出也打印到*cider repl*
;; run this code on the repl where you wish to see all output.
;; You will need to add the dependency [commons-io "2.4"] to your
;; leiningen dependencies.
(import 'org.apache.commons.io.output.WriterOutputStream)
(import 'java.io.PrintStream)
;; First, we redirect the raw stdout of the server to this repl
(System/setOut (PrintStream. (WriterOutputStream. *out*)
true)) ;; Auto-flush the PrintStream
;; Next, we alter the root binding of *out* so that new threads
;; send their output to THIS repl rather than the original System/out.
(alter-var-root #'*out* (fn [_] *out*))
;; Now the snippets should both send output to this repl:
(.println System/out "Hello stdout.")
(.start (Thread. #(println "Hello from a new thread.")))
error in process filter: [nREPL] No response handler with id nil found