Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Java went through java.util.logging, Log4j 1, Commons Logging, SLF4J, Logback and Log4j2, and many applications still ship several of them. Explain why the ecosystem fragmented this way and what standard you would set for a company with hundreds of Java services today.

The ecosystem fragmented because Log4j 1 was adopted first, java.util.logging arrived later in Java 1.4 as a weaker built-in option, and libraries could not agree on one API, so Commons Logging tried to be a facade and caused classloader trouble, and SLF4J replaced it with a simpler binding model, followed by Logback as its native backend and Log4j2 as a rewrite. Today I would set one standard: libraries log only through the SLF4J API, each application has exactly one backend, Logback by default as in Spring Boot or Log4j2 when there is a reason, and every other API is routed into it through bridges, with Log4j 1 removed. I would enforce it with dependency rules, a shared logging starter with structured JSON output and a named owner for upgrades and CVE response.

Why this question is asked

Open any large Java service's dependency tree and there is a good chance it contains three or four logging libraries, some of them abandoned. This is not carelessness; it is the residue of twenty years of history, carried in through transitive dependencies. Interviewers ask this at the senior level because a sensible standard depends on understanding why the mess exists, and because the business case, which became very clear with Log4Shell, has to be made to people who do not care about logging. In this answer, we will walk through how the fragmentation happened, see what each piece does today, write the standard, plan its enforcement, and make the business case.

1How the Fragmentation Happened

Around 2001, Log4j 1 was the logging library for Java; it introduced the logger hierarchy, appenders and layouts that every later framework copied. In 2002, Java 1.4 added java.util.logging, usually called JUL. It arrived late, was less flexible than Log4j and configured through a single JVM-wide file, so many projects kept Log4j while the JDK and some libraries used JUL.

Library authors then had a problem: whichever API they chose, some of their users had the other. Jakarta Commons Logging, JCL, tried to solve it as a facade, an API that discovers the real logging system at runtime. Its discovery used classloader tricks that broke in application servers with several classloaders, producing memory leaks and the wrong backend being picked.

In 2005 and 2006 the original author of Log4j created SLF4J, a facade with a much simpler rule: the binding is chosen by which jar is on the classpath, with no runtime discovery magic. He also wrote Logback as SLF4J's native implementation. Apache later rewrote Log4j from scratch as Log4j2, with async loggers built on a ring buffer and a plugin system. Log4j 1 reached end of life in 2015 and must be removed, though a compatible fork, reload4j, exists for code that cannot move yet. SLF4J 2.0 later replaced static binding with ServiceLoader providers.

What each piece is today
LibraryRoleStatus in a new standard
SLF4J APIfacade used by codethe only API for libraries and applications
Logbackbackend, SLF4J nativedefault backend (Spring Boot default)
Log4j2backend with async loggersallowed backend with a reason
java.util.loggingJDK built-in APIbridged into SLF4J (jul-to-slf4j)
Commons Loggingold facadebridged (jcl-over-slf4j or Spring's own bridge)
Log4j 1end of life since 2015removed; log4j-over-slf4j for old callers

2The Standard for Libraries and Applications

The core rule separates libraries from applications. A library, meaning any jar used by other code, depends only on slf4j-api and never on a backend, because the choice of backend belongs to whoever runs the code. An application chooses exactly one backend. For Spring Boot services, that is Logback, which Boot configures by default; Log4j2 is allowed when a team has a measured reason, such as very high log throughput where its async loggers help.

Because third-party libraries still call JUL, JCL or the Log4j 1 API, the application routes those calls into SLF4J with bridges: jul-to-slf4j, jcl-over-slf4j and log4j-over-slf4j, and log4j-to-slf4j for libraries that use the Log4j2 API. Bridges must always point towards the chosen backend, never in a circle, because a bridge and its opposite adapter on the same classpath create an infinite loop. Spring Framework has its own bridge for Commons Logging calls, so check your Spring version for whether jcl-over-slf4j is still needed.

XML
<!-- In the shared parent POM: ban what the standard removes -->
<rule implementation="org.apache.maven.enforcer.rules.dependency.BannedDependencies">
<excludes>
<exclude>log4j:log4j</exclude> <!-- Log4j 1, end of life -->
<exclude>org.slf4j:slf4j-log4j12</exclude> <!-- 1.7 binding to Log4j 1 -->
<exclude>org.slf4j:slf4j-simple</exclude> <!-- second backend -->
<exclude>org.apache.logging.log4j:log4j-slf4j-impl</exclude> <!-- SLF4J 1.x binding -->
</excludes>
</rule>

A service that has chosen Log4j2 uses a variant of the rule that bans logback-classic instead. The rules matter most for transitive dependencies, which is where old Log4j 1 jars usually hide.

3Enforcing It Across Hundreds of Services

Standards that live in documents drift. This one is enforced in four places. First, dependency rules such as the enforcer rule above, or Gradle dependency constraints and resolution rules, fail the build when a banned artifact appears, directly or transitively. Second, a shared logging starter brings the bridges, the backend configuration and a structured JSON format with fixed field names, so teams do not each write logback-spring.xml from scratch. Third, a dependency scan across all repositories reports which services still carry exceptions. Fourth, there is an owner: a platform team responsible for the logging versions in the company BOM, for upgrades and for the response when a logging CVE appears.

Exceptions are allowed, with a reason and an expiry date. A vendor jar that cannot avoid Log4j 1 classes might use reload4j for a while; the exception list makes that visible instead of hidden.

Step throughWhere a logging call ends up under the standard
  1. Code calls SLF4J, JUL, JCL or Log4j 1 APIour code or a third-party library
  2. Is it the SLF4J API?
    YesGoes straight to the providerNoA bridge converts it to SLF4J
  3. SLF4J providerlogback-classic, or log4j-slf4j2-impl if Log4j2 is chosen
  4. One backend writes JSONconfigured by the shared starter

4 steps in order. Play them, or step through them one at a time.

4Making the Business Case

To people outside engineering, logging standards sound like tidiness. The case is about risk and cost. When Log4Shell, CVE-2021-44228, was published in December 2021, companies with one known backend and a BOM answered 'are we affected?' within hours and patched with one version bump. Companies with logging libraries scattered through transitive dependencies spent weeks searching jars, including shaded copies inside other jars. One patch path is the strongest argument.

The second argument is consistency for the log platform: one configuration model and the same fields, timestamp, level, service, trace id, in every service, which makes cross-service queries possible and on-call work faster. The third is onboarding: an engineer who moves teams already knows how logging is configured.

5Follow-up questions

Would you allow a team to choose Log4j2 over Logback? On what grounds?

Yes, with a reason that is measured rather than a preference: for example, a service that logs at very high rates where Log4j2's async loggers show lower latency in a benchmark on our workload, or a need for a specific Log4j2 feature. The team still logs through SLF4J, uses the shared JSON format and field names, and accepts that the platform team supports both backends, so the number of such exceptions should stay small.

Why not standardise on java.util.logging since it is built in?

Because almost the whole ecosystem, including Spring Boot, is built around SLF4J, and JUL's configuration model, one JVM-wide configuration, is weaker for applications. JUL is fine for very low-level code that must have no dependencies, which is also a reason System.Logger exists, but routing it into SLF4J is simpler than routing everything into JUL.

What do you do about shaded copies of Log4j inside other jars?

Dependency rules do not see them, because the classes live inside another artifact under a different package name or even the original one. A binary scan of the built application, such as a software composition analysis tool that inspects class files, is needed to find them, and the owning vendor must provide a fixed release.

6Conclusion

In this answer, we traced how Log4j 1, java.util.logging, Commons Logging, SLF4J, Logback and Log4j2 arrived one after another, each answering a problem the previous one left. We set a standard in which libraries use only the SLF4J API, applications pick one backend, Logback by default or Log4j2 with a reason, and all other APIs are bridged towards it, with Log4j 1 removed. We enforced it with dependency rules, a shared starter with JSON output and a named owner, and justified it with a single patch path for CVEs like Log4Shell, consistent fields and simpler onboarding.

What to say in the interviewAbout 100 seconds aloud

Open with

The fragmentation is mostly a story of timing. Log4j 1 came first and set the model with loggers, appenders and layouts. java.util.logging arrived in Java 1.4 as a built-in but weaker option, so libraries could not agree on one API.

Then, if they want more

Commons Logging tried to be a facade, but its runtime discovery broke in application servers with several classloaders. SLF4J replaced it with a simpler model where the binding comes from the classpath, and in 2.0 from ServiceLoader providers. Logback was written as SLF4J's native backend, and Log4j2 was a full rewrite with async loggers.

Log4j 1 has been end of life since 2015. For a company today, my standard would be: libraries depend only on slf4j-api, never on a backend. Each application has exactly one backend, Logback by default because that is what Spring Boot uses, or Log4j2 if a team shows a measured need.

JUL, Commons Logging and Log4j 1 calls are routed into SLF4J through bridges, always towards the chosen backend, and Log4j 1 itself is banned.

I would enforce that with enforcer or Gradle rules that fail on banned artifacts including transitive ones, a shared logging starter with structured JSON and fixed field names, a dependency scan across repositories and a platform team that owns versions and CVE response.

The business reason is Log4Shell: with one backend and a BOM, you know within hours whether you are affected and you patch with one version bump.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Java went through java.util.logging, Log4j 1, Commons Logging, SLF4J, Logback and...": https://scrivio-interview-library.netlify.app/java/java-logging/a4a15c36bd/