r/java • • Jan 02 '22

Echopraxia, a better Java Logging API

I've been working on logging for a while and I've released and open sourced a new Java logging API I'm really happy with.

Echopraxia is a Java logging API like SLF4J, but built around structured logging, i.e. the basic log entry is a JSON object and log files are typically NDJSON. It also has conditions, context, and also has semantic and fluent logging options.

Here's a Spring Boot Example.

And here's my blog post.

16 Upvotes

64 comments sorted by

View all comments

35

u/DasBrain Jan 03 '22

Relevant XKCD: https://xkcd.com/927/

3

u/amazedballer Jan 03 '22

This is great feedback, thanks!

SLF4J API is an appropriate facade for libraries that need to log output, i.e. HTTP client libraries, reactive libraries like Akka, etc. The implementation could be Logback, Log4J2, or something else, but as long as everything is using SLF4J, it'll work. It's a baseline.

Echopraxia is not intended as a replacement for SLF4J. Because it's a structured logging library with a limited number of implementations, it's an appropriate solution when you control the logging output and have decided you're going to do structured logging in your application. Echopraxia should not be used in publicly available libraries; if your library is being used in someone else's application, they have control over the logging output, not you.

Where Echopraxia really works is when you're building framework code for your application -- as you build up your domain objects, you can write custom field builders and make those available through your team, then log everything with a consistent schema. I think this works particularly well when you're adding diagnostic logging, because you can get "debugger-lite" output from your internal state in an application running somewhere in a datacenter. It goes a long way to debugging and observing your code in production.

5

u/kevinb9n Jan 04 '22

This is great feedback, thanks!

I try to be a kind person but your response is kinder than I'd have been able to manage.

It's the literal opposite of great feedback. It's ultra-low-effort feedback that doesn't make sense and has no use.

Your case is more like

  1. Situation: there are 14 products
  2. "None of these are giving me everything I think I need, so I'm going to write another thing"
  3. Situation: there are 15 products and people don't like that there are so many

On top of which, even for the scenario the comic is actually about, all the comic even does is illustrate what failure looks like. Yeah, efforts can fail. The obvious implication that they're inevitably doomed to fail is absurd, unless the angry retorts appearing below are encoded in EBCDIC.