Understanding Java Logging Frameworks: Relationships, Dependencies, and Configuration

This article explains the evolution and inter‑relationships of Java logging libraries such as JCL, SLF4J, Log4j, Logback and JUL, shows how to choose and configure adapters to achieve unified logging across frameworks, and provides troubleshooting tips and coding guidelines.

Top Architect
Top Architect
Top Architect
Understanding Java Logging Frameworks: Relationships, Dependencies, and Configuration

The purpose of this article is to clarify how various Java logging libraries relate to each other, their roles, dependencies, and how to resolve common problems like missing logs or jar conflicts, as well as how to unify logging output across different frameworks.

Log ecosystem history : Early on log4j became the de‑facto standard. Sun added java.util.logging (JUL) in JDK 1.4, leading to multiple competing APIs. Apache introduced JCL (commons‑logging) as a thin façade, while Ceki Gülcü created SLF4J to replace JCL and later released logback for higher performance. Apache subsequently built log4j2 on top of logback ideas.

Relationships and dependencies : JCL provides only an API and relies on an underlying implementation. SLF4J also offers a façade and requires an adapter to bind to a concrete logger such as Logback, Log4j, or JUL. Typical adapter combinations include: slf4j-api.jar + logback-classic.jar +

logback-core.jar
slf4j-api.jar

+ slf4j-log4j12.jar +

log4j.jar
slf4j-api.jar

+

slf4j-jdk14.jar
slf4j-api.jar

+ slf4j-nop.jar (no logging implementation)

For projects using JCL or Log4j directly, the corresponding SLF4J bridges ( jcl-over-slf4j.jar, log4j-over-slf4j.jar, jul-to-slf4j.jar) allow seamless migration to SLF4J.

Practical adaptation example : Spring uses JCL as its logging façade. To make Spring log through Logback via SLF4J, simply add jcl-over-slf4j.jar to the classpath and remove other conflicting logging implementations.

Common issues : Failed to load class org.slf4j.impl.StaticLoggerBinder – indicates no concrete logger bound; usually a version‑compatibility problem. Multiple bindings – multiple logger implementations are present; SLF4J will pick one, which may cause unpredictable behavior.

Code style recommendation : Follow Alibaba’s guideline to depend only on the SLF4J API ( org.slf4j.Logger, org.slf4j.LoggerFactory) instead of directly using Log4j or Logback APIs, ensuring consistent logging across modules.

Conclusion : The article maps out the Java logging landscape, explains how to resolve typical logging conflicts, and provides a clear path to unify logging output using SLF4J and appropriate adapters.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Javalogginglogbackslf4jjcl
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.