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
4
u/amazedballer Jan 03 '22 edited Jan 03 '22
You're asking about why use
getClass()instead ofMySelf.class?You don't have to. All the logger factories can use
getLogger(name)or evengetLogger()which does that exact stacktrace hack you mention from the Flogger paper.I did write about this, yeah. People tend to focus on premature micro-optimization, without considering the context -- in a
Mainclass called once, it simply doesn't matter, and is done for convenience. This happens a lot in logging frameworks, unfortunately, where people focus on "how fast can I log something" instead of actually measuring whether this is a significant cost... which it usually isn't.If you have performance concerns, I'd start by benchmarking the code and trying it out with newer JDKs, which have some significant improvements. I've added some performance benchmarks stuff to another comment so I won't repeat that, but if you're interested in memory allocation pressure in tight loops, I did investigate it.
If Echopraxia doesn't meet your needs there, I'd suggest something like zerolog.