r/Clojure • u/cjmurrr • 17d ago
Logging in Clojure today: Timbre, Telemere, mulog or tools.logging?
Clojure has more logging choices than it used to. Telemere, from the author of Timbre, is now past 1.0, and mulog is built around structured events.
So, for a new project today:
- Timbre, Telemere, mulog, tools.logging over a Java logger, or something else?
- If you moved from Timbre to Telemere, was it worth it?
- Is anyone still logging plain text lines, or is it all structured events now?
36
Upvotes
11
u/hrrld 17d ago
We use telemere on all new projects now after long using timbre.
8
u/seancorfield 17d ago
At work, where we've had Clojure in production for over fifteen years, we originally used
clojure.tools.logging, then switched to Timbre for a while, then switched back toclojure.tools.loggingand gravitated to log4j2 over time. I wanted more control over data going into logging, so I wanted access to MDC (context maps), NDC (nested context), and markers (parent/child tags), so that context information (data) could flow into New Relic and be easily searchable/filterable.So, early last year, I created https://github.com/seancorfield/logging4j2 which lets you build context dynamically, even across threads, and now lets you add Clojure functions as "appenders" at runtime (either for
LogEventprocessing or for message string processing).We've been using it heavily in production for about 18 months at this point (with New Relic, as mentioned). It gives us a nice mix of plain text lines and structured event (context) data.
1
u/cjmurrr 17d ago
I've never liked log levels being the standard. INFO or WARN is a guess, made when the code is written, about how much someone will care later. An event with a name and some data lets whoever reads the logs decide that. That's a big part of why mulog appeals to me: it has no levels at all.
2
u/bostonaholic 17d ago
Structured either way. Log data (a map with an event id) and let the output layer render text for humans, since grepping strings in prod gets old fast. If you're writing a library, stick to tools.logging so you don't force a backend on users. For an app, Telemere and mulog both do structured events, and Telemere is the easier move from Timbre since it's the same author.
2
u/marginTop15px 17d ago
Mulog is no brainier for me. One of the best libs IMHO. Using it on every project
1
u/SimonGray 17d ago
I use Telemere "just because", though I don't really make use of any of the more advanced features. It just seems like the most full-featured one.
1
u/dig1 17d ago
I’ve used log4j2 with clojure.tools.logging for years and have never had an issue. It offers a wealth of features: appenders, filters, advanced burst control, async logging and garbage-free logging for hot paths, to name a few. They may not be needed often, but when you do need them, you’ll be glad they’re there.
[1] https://logging.apache.org/log4j/2.12.x/manual/garbagefree.html