Better Java logging, inspired by Clojure and Rust (II)

by: Ethan McCue

Around three months ago I wrote a pretty long rant about a Java logging library I doodled out.

My goal was to dream up something that would fill the same ecosystem role as SLF4J but with the primary goal of supporting the logging of structured data.

I got an absolute mountain of good feedback. After spending some time reading and internalizing the responses, I realized a few things.

  1. I need to more effectively communicate my intent. Writing about the nitty-gritty details about choices in API design is my marmalade sandwich, but I need to do that after explaining what I am going to do and why.
  2. Going forward, I need to properly contextualize how everything would interact with OpenTelemetry. Yes, OTel provides an API for propagating context, but OTel would not be suitable to include in a library. There is still a role here for something which lets a library interact with that concept without including OTel outright.
  3. All the opining about ExtentLocals (now called ScopedValues) was a bit tangential, but I do stand by the choice of making the API only propagate scope inside lambdas in preparation.
  4. I need to be more mindful of allocations in general, but still think that having a reified but restricted set of log values is important and paying whatever cost there is to allocate those objects is worth it.
  5. The API I was making was doing way too much. The ring buffer, the context stack, all the thread and timing info I was attaching to Log records - all of those are still valid directions to go with a logging implementation, but not with a logging interface.

Related to the last two points - I've written up a new draft of the API without any of the context implementation and minimizing allocations down to just the log entries. This has required a few changes - farewell my sweet prince log, the method which logs a Log - but so far seems to be okay. I'm not entirely sold on how I am handling context now though.

You can find all of that on my GitHub under log.beta.

I am writing this tiny update to give myself permission to put this on the hammock for a time and move on to some other fiddly, controversial, and fun topics. Stay tuned for that.

If you want to talk about this, feel free to reach out directly by any means necessary.

<- Index