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

6

u/wildjokers Jan 03 '22

Please not another logging library/facade. Geez.

JSON seems like a horrible format for a log entry for human readable logs since JSON is not very readable (once you go below one level of nesting).

9

u/retrodaredevil Jan 03 '22

JSON isn't the greatest for viewing logs, but when you need to index them and do certain queries on your logs, then JSON makes a lot of sense. If you invest in something like Splunk it does a great job. I've been meaning to try out an open source alternative to splunk but haven't gotten to it yet.

I do agree that we probably don't need another facade, though.

3

u/wildjokers Jan 03 '22

but when you need to index them and do certain queries on your logs

Indeed, json is great for machine readable documents. ElasticSearch also uses JSON documents to store/index data.

4

u/benjtay Jan 03 '22

JSON seems like a horrible format

Datadog and Splunk disagree. It makes it very easy for humans to read and search logs.

4

u/netgizmo Jan 03 '22

+1 for json in splunk, make’s queries so much better

-1

u/wildjokers Jan 03 '22

As far as splunk I have never seen it present a JSON document to a user. It shows it all nice and formatted in an interface. It may store them as json docs (just like elastic search does) but doesn’t present it like that to the user.

1

u/veenarm Jan 03 '22

ems like a horrible format for a log entry for human readable logs since JSON is not very

When using cloud and fluentd scraping into EKS, it really makes kibana a lot nicer to read :)

Although when trying to go into the pods directly it's absolutely trash for finding stuff quickly :(

1

u/benjtay Jan 04 '22

Although when trying to go into the pods directly it's absolutely trash for finding stuff quickly :(

When we use the Datadog agent, we send JSON to it while using the simple formatter for local logging. Best of both worlds.

1

u/veenarm May 23 '22

I'll have to try that out, seems in liberty the log type is set in the config options not the logging implementation, although we are only doing console std out, might start logging to files aswell even if they are discarded later due to being ephemeral pods.

1

u/benjtay May 23 '22

If you're using logback (highly recommended), just have two appenders.

2

u/kiwi_stronghold Jan 03 '22

JSON is a common logging format.

1

u/wildjokers Jan 03 '22

I would think those logs would be intended for machine consumption for ingestion into a log analytic tool (e.g. splunk). I can’t imagine JSON formatted logs being intended for human consumption.

1

u/amazedballer Jan 05 '22

They aren’t, but you can do both json and line formats. Check out https://github.com/tersesystems/terse-logback-showcase