Fork me on GitHub
#babashka
<
2023-09-30
>
hifumi12306:09:31

Is it possible to make clojure.tools.logging log to stderr in babashka? As an experiment, I ran the container with podman run --rm -it babashka /bin/sh -c "/bin/bb 2>/dev/null" and attempted to log, but I can see logs in my terminal, so I assume the logs are being sent to stdout

borkdude10:09:08

is it possible to change the default logger in clojure.tools.logging? this is how it should probably be done. the default logging code is here:

borkdude10:09:13

@U0479UCF48H you can change the default logger to log to std-err by tweaking the timbre logger:

(alter-var-root #'log/*config* assoc-in [:appenders :println] (log/println-appender {:stream :std-err}))

gratitude 1
hifumi12310:09:17

if i recall correctly, the logger factory is chosen based off a certain order: first tools.logging attempts reading SLF4J, then a bunch of other options, and ends at JUL

borkdude10:09:26

(require '[taoensso.timbre :as log])

hifumi12310:09:42

Yeah, I was just about to mention that Timbre seems to be default logger on bb, so I can use a custom output function in Timbre. I have done this in the past