Hacker News new | ask | show | jobs
by paulmd 3700 days ago
Yeah, it's the exact situation described in that XKCD: "There are 14 competing standards! Let's create one that is perfect for everyone's use-case!" "There are 15 competing standards..."

https://xkcd.com/927/

And, as you noticed, pretty much every Java project will reach a point where it has to deal with all four-ish of the major logging frameworks. Some module, somewhere, will include an Apache dependency and then you get JCL, and some other purist will insist on java.util.logging and away you go.

With that said, it really isn't that bad to fix. You can use the SLF4J bridge modules and dump all 4 of the logging systems to a single output system. This doesn't actually have to be via SLF4J either - there are modules to dump SLF4J out to JCL or JUL or whatever.

http://www.slf4j.org/legacy.html

This is one of those things about Java that's annoying as hell to get set up, but you plug through it for an hour and then you never need to touch it again. And the next time you can crib from your working build and 99% of it will be the same.

2 comments

I like to imagine that particular XKCD was written with Java logging in mind.
I doubt that you have used the SLF4J bridge in any realsitic situation, else you would not say that it works.
I have and it works fine.
I don't believe you.

Even the docs say it does not work w/ multiple loggers. But I'm not here to teach, good luck.

You're quite simply wrong - the docs do not say that anywhere.

What they do say is that you are not allowed to route loggers circularly - if you route (for example) JUL through SLF4J, you are not allowed to route that output back to JUL, otherwise messages would never be dumped to output.

That's why I said that you have not used it in anger in production environments. Anyway, good luck.