r/java • u/agentoutlier • Feb 27 '24
Rainbow Gum a JDK 21+ GraalVM native friendly SLF4J implementation experimental release.
Sometime before the Log4shell attack I criticized the Log4J2 team that it had gotten overwhelmingly bloated and while Logback is less bloated it still was not small enough for my liking. I complained that there really needed to be a log4j2 light.
Furthermore at the time (and mostly still the case) neither Log4j2 nor Logback worked well with GraalVM native images as reflection is used extensively in both frameworks.
I believe Ralph from Log4j2 response was more or less make your own implementation.
Several years later and I have finally done that.
https://github.com/jstachio/rainbowgum
Rainbow Gum is an SLF4J implementation that:
- Uses zero reflection
- Has zero use of
synchronized - Heavily uses JDK 21+ features like sealed classes and pattern matching
- Heavily modularized.
core(API) is actually a smallcoreand not a 1MB kitchen sink. - The initialization is massively faster than log4j2 and even logback both programmatic and especially if their XML formats are used.
- superior javadoc (in fact the user guide is made from javadoc)
- follows Spring Boots property configuration style (
logging.level...etc).
The readme and the user guide cover many more of the reasons of why a new logging implementation is a good thing.
0.2.0 is now in Maven central.
I will edit this post later with more links (if you add too many you get automod).
22
u/agentoutlier Feb 27 '24
The documentation is here: https://jstach.io/doc/rainbowgum/current/apidocs/
Like JStachio (my other project) I continue to push the javadoc system to its limits and found numerous snippet bugs either with Eclipse, IntelliJ or the JDK itself.
That being said JDK 21+ kicks ass. So many good features.
13
u/Joram2 Feb 28 '24
Is there support for the JDK 9+ logging facade, System.Logger (https://docs.oracle.com/javase/9/docs/api/java/lang/System.Logger.html) in addition to the third party logging facade SLF4J?
2
u/Maran23 Feb 28 '24
You specified that there is no ability to reload loggers. Does that mean you can not change the level of a logger/namespace during runtime? That is somewhat bad as I pretty often switch something to TRACE in production to get more information (e.g. XML logging) on bigger projects.
But I really see a huge benefit for smaller projects where this is not needed at all, I have in fact one where I will try it out!
2
u/Rongmario Feb 28 '24
Have you compared this to the alpha log4j3 builds? The startup and footprint should be a lot smaller, it'd be very nice if this competes with that.
2
u/lurker_in_spirit Feb 28 '24
Honestly, the only feature I can think of that might get me to check out a new logging framework is nice interop with string templates. Have you put any thought into what this might look like?
8
u/TheKingOfSentries Feb 28 '24
You really push Javadocs to their limit, I gotta learn how to do that
4
u/rbygrave Feb 28 '24
Great stuff, I'll give it a whirl. I'm really keen on a lighter logger and this looks like it will fit well.
2
u/benjtay Feb 28 '24
Awesome work. I'm definitely checking this out.
2
u/BestBid4 Feb 28 '24
Well done. I really hate using log4j & logback.
-12
u/menjav Feb 28 '24
Congrats!
Ouch. In the industry, big companies are still using JDK8. When we jump to something else, we might jump to JDK11 or JDK17. I would try a new logger only if it’s (almost) a drop in replacement.
Id suggest to target the current LTS versions. But off course, I’m a random person in internet and you’re free to implement whatever you like.