Fork me on GitHub
#cider
<
2024-05-15
>
jpmonettas15:05:58

is there a way to configure java.utils.logging (in logging.properties) or cider so logs show in the repl window as everything that writes to *out* does? I prefer this window to the *cide-log* buffer

vemv15:05:32

It looks like you're using cider-log-mode, is that the case? If so, that's a completely opt-in mode

jpmonettas15:05:14

not sure I follow, so basically what I want is to be able to use clojure.tools.logging with whatever framework, but make the logs show up in the repl buffer, like println does

vemv15:05:11

There's no *cider-log* buffer that I know of (other than cider-log-mode's, in which case it's opt-in)

jpmonettas15:05:49

yes, but I don't want to use *cider-log* , just the repl window

Samuel Ludwig15:05:31

ah yea this could be interesting too for stuff like malli's nice dev errors!

jpmonettas15:05:28

isn't there some nrepl appender I can use so whatever goes in logs ends up in nrepl *out* messages?

vemv15:05:55

> yes, but I don't want to use *cider-log* , just the repl window Yeah, what I meant is, don't use it then, then it goes to the repl buffer

jpmonettas15:05:35

so, you mean if I start a clojure repl with clojure.tools.logging, and I do a (log/info "hello") that should end up in the repl buffer?

vemv15:05:53

I think so. Sometimes if you start a repl in e.g. iTerm and cider-connect to it, the logging will go to iTerm, not emacs. But with cider-jack-in, I'd be surprised if logging would go literally nowehere

jpmonettas15:05:02

from what I'm trying it just get lost. Which makes sense, because by default it will write to the console, and there is nothing capturing that. The only thing that is being captured is whatever goes into *out* and *err* streams

vemv15:05:45

TIL then! This has always been a funky area Perhaps we could have System/setOut / System/setErr calls to achieve a similar effect (and I'd be surprised if we don't have anything similar ready)

jpmonettas15:05:09

oh interesting, that could work I guess

jpmonettas15:05:26

hmm now I bridged everything to log4j2 and it is showing on the cider repl. Jeez, logging is so complicated

🌀 1
vemv16:05:13

For completeness, we do have setout https://github.com/clojure-emacs/cider-nrepl/blob/41e2787d372efd0f648cc586a8d338a24f9d3a32/src/cider/nrepl/middleware/out.clj#L160-L161 maybe it's some sort of race - perhaps if some printing before that code is executed, then that earlier bird wins?

jpmonettas16:05:58

not sure, when I was trying with no frameworks, which made clojure.tools.logging default to java.utils.logging it wasn't showing at any level, no matter my logging.properties config. Then I added all dependencies to bridge all frameworks to log4j2, configured log4j2.xml and now it is showing :man-shrugging: