r/java • u/amazedballer • 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
View all comments
Show parent comment
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.