Closed theronic closed 4 years ago
This seems to work (via SO question):
;; 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.")))
I'm using Timbre for my logging. When I connect to an nREPL in production, I can't see the log output unless I SSH into the machine and run
journalctl
, since my Java process is managed by systemd.Is there a way to multiplex Timbre logs to the nREPL client?