我使用Timbre来登录Clojure。当我通过nREPL连接到生产实例时,除非我通过SSH连接到机器并运行journalctl,否则我看不到进程日志。
如何对音色日志进行多路复用,使其在nREPL中可见?
我怀疑我需要修改*out*变量。
发布于 2020-06-06 20:47:13
在这里找到了答案:https://stackoverflow.com/a/38294275/198927
;; 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.")))https://stackoverflow.com/questions/62230777
复制相似问题