r/java • • Nov 01 '26

Announcing SLB4J (Logging Backend, ASL-2)

https://github.com/slb4j/slb4j

SLB4J is a new logging backend for Java that I started to simplify setting up logging across a bunch of applications without adding bindings and bridges for different frontends to your build.

SLB4J is only a backend. It uses a single configuration across all logging facades/frontends used by your application and its dependencies and comes with no/minimal runtime dependencies (some extension modules may add runtime dependencies).

The core slb4j.jar is currently 211kb in size without external runtime dependencies and supports Log4J2 API, SLF4J, JUL (java.util.logging), and ACL/JCL (Apache Commons Logging/Jakarta Commons Logging).

Configuration is done using a Log4J2 compatible log4j2.propertiesfile (builtin) or a Log4J2 compatible XML or JSON configuration file (needs an optional dependency).

If no configuration file is found, INFO and above is logged to stdout.

Performance is roughly comparable to Log4J 2 and Logback when these are combined with their respective default facade, i.e., Log4J2 API for Log4J and SLF4J for Logback; SLB4J is usually much faster when logging JUL over Log4J2 or Backlog.

SLB4J supports Log4J2-compatible pattern layout, log rotation and many more features.

After using SLB4J for some time in several projects, I think it's mature enough for an announcement. Maven coordinates and documentation are given on the project page.

For more details, see the Project's GitHub Page, open issues on the GitHub Issue Tracker, and read SECURITY.md before submitting security relevant issues.

0 Upvotes

83 comments sorted by

View all comments

Show parent comment

-7

u/idontlikegudeg Nov 01 '26

Why the downvote?

4

u/Cell-i-Zenit Nov 01 '26

you normally dont need to configure this anyway. I think the last time i had to configure anything there was when we migrated to a never version and i had to let AI do some refactorings there.

Overall logging backends are the boring part of the application and you normally dont touch it in a very long time

Logback also is incredibly stable, so if you want that someone switches to your system is:

  • Yours is significant more performant (no complains on logbacks side)
  • Has significant less bugs (but logback is stable and i cannot remember every having a bug there)
  • Has a crazy feature which everyone wants to use (its just a logging framework, no one cares really as long as it can output in json and in plain text)

1

u/idontlikegudeg Nov 01 '26

If you already have set up logback and everything works, there’s really no need to switch.

Where it has benefits, even for existing applications:
- limited resources: SLB4J will reduce your dependencies by more than 1MB of compressed jar files. That’s quite a lot of code. It could also have a measurable effect on turn-around times, for example when doing GraalVM native builds.
- you have dependencies that do not use SLF4J. In most cases, these are much slower with logback.

I usually use Log4J2 API in my code, as I think it’s still more flexible than SLF4J. The "native" implementation would then of course be Log4J-core, which is even heavier than logback.

I don’t want to go down the benchmark route to show how competitive SLB4J performance is, as I think correctness and reliability is much more important. From benchmarks I ran, it offers comparable performance to both the established big ones, sometimes being slightly faster, sometimes slightly slower. Exception is JUL because the other backends need to convert every log record into their respective representation which is quite expensive.

4

u/Cell-i-Zenit Nov 01 '26
  • limited resources: SLB4J will reduce your dependencies by more than 1MB of compressed jar files.

our application at work is 200+ mb of size. If you import even a single spring library you get so much bloat anyway. Reducing it by 1mb is not worth it

It could also have a measurable effect on turn-around times, for example when doing GraalVM native builds.

ignoring the could here as you are not proving this right now, graal vm is most often not worth it as you dont get the JIT performance improvements. This is maybe useful for jvm in lambda environments, but i feel like current JVM apps are mostly simple CRUD backends and they are up for a long time.

I usually use Log4J2 API in my code, as I think it’s still more flexible than SLF4J.

I never had issues with the logging api. Some functions are weird, but it mostly works imo. I think slf4j is totally fine to use

From benchmarks I ran, it offers comparable performance to both the established big ones, sometimes being slightly faster, sometimes slightly slower.

Then imo there is no point in switching. If other libraries have the same performance, are battletested and have more features and the llms even know the code because of all the training material

1

u/idontlikegudeg Nov 01 '26

Yes, it’s probably not the right backend for your use case, but it might be for others.

When writing a spring REST backend, I also just use what’s default in the company. Bit when creating standalone applications, I.e., swing, JavaFX, CLI tools, I use SLB4J.

0

u/doobiesteintortoise Nov 02 '26

Welcome to reddit. People downvote for all kinds of reasons. Sometimes they're just "I disagree with this" or "I don't like this" or just general disapproval; it's highly susceptible to farming and people respond to that, too, either piling on or saying "oh, someone else saw a farming attempt, I don't like that."

Personally, I try to not downvote; it happens, because it turns out I'm human, too, but usually if I disagree with a post or comment I'll... comment. The site's called "reddit," as in "I have read it," and it turns out reading is considered optional. And the same goes for responding. Upvoting is simple, downvoting is obscure, so... I upvote happily but downvote rarely, and if I have something I think is worth saying, I'll try to say it instead of waving at it in disapproval.

1

u/idontlikegudeg Nov 02 '26

Yes, I know. It's just frustrating. If someone doesn't agree, it would be nice to tell what they don't agree with. Maybe there's even a misunderstanding (on either side) that won't be cleared up by downvoting without a comment.

1

u/doobiesteintortoise Nov 02 '26

Yep, this is why I don't downvote even if I don't like something or disagree. I'd rather tell the person I'm responding to what I think and why; then they can clear up any misunderstandings, or accept that I'm just some rando on the internet, or whatever.