Master Java Logging: Decode Framework Relationships & Fix Common Issues

This article explains the evolution and inter‑dependencies of Java logging frameworks such as JCL, Log4j, JUL, SLF4J and Logback, shows how to configure them to avoid jar conflicts and missing logs, and provides practical steps and troubleshooting tips for unified logging in Java projects.

ITFLY8 Architecture Home
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Master Java Logging: Decode Framework Relationships & Fix Common Issues

Overview

The purpose of this article is to clarify the relationships among various Java logging libraries, how they work together, and their dependencies, so that developers can troubleshoot problems like missing logs or jar conflicts and achieve consistent log output across frameworks.

Log System

Typical projects may depend on many logging‑related jars, such as commons-logging.jar, log4j.jar, slf4j-api.jar, logback.jar, etc. Proper configuration requires understanding how these jars interact.

Background / History

log4j (by Ceki Gülcü) became the de‑facto Java logging standard and an Apache project.

Apache wanted to integrate log4j into the JDK, but Sun refused; JDK 1.4 introduced JUL ( java.util.logging ).

Because JUL is bundled with the JDK, many developers use it alongside other simple loggers like SimpleLog.

Apache created JCL (Jakarta Commons Logging) – a generic logging API without an implementation, allowing runtime selection of the actual logging backend.

Ceki Gülcü later developed SLF4J , a façade similar to JCL, and logback , a high‑performance implementation intended to replace log4j.

Apache then built on logback’s ideas and released log4j2 .

Relationships / Dependencies

JCL

commons-logging

is no longer maintained.

JCL is used by few components nowadays.

SLF4J

SLF4J provides adapters for the major logging implementations, allowing a project to use SLF4J as a façade while delegating to Logback, Log4j, JUL, or a no‑op implementation.

SLF4J + Logback: slf4j-api.jar + logback-classic.jar + logback-core.jar SLF4J + Log4j: slf4j-api.jar + slf4j-log4j12.jar + log4j.jar SLF4J + JUL: slf4j-api.jar + slf4j-jdk14.jar SLF4J only (no logging): slf4j-api.jar +

slf4j-nop.jar

SLF4J Adaptation

SLF4J can adapt any existing logging framework via specific bridge jars:

JCL → jcl-over-slf4j.jar Log4j → log4j-over-slf4j.jar JUL →

jul-to-slf4j.jar

Overall dependency diagram (illustrative):

Unifying Spring Output

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.

Adaptation Steps

Identify which logging component each module or framework uses, then locate the appropriate SLF4J bridge.

Remove unused logging implementations, keeping only the desired one.

Common Issues

Failed to load class org.slf4j.impl.StaticLoggerBinder

No logging implementation was found; usually caused by missing or incompatible bridge jars.

Multiple bindings

Multiple logging implementations are present; SLF4J will pick one, which may lead to unexpected behavior.

Code Standards

【Mandatory】Do not use Log4j or Logback APIs directly; depend on SLF4J API instead. Example: import org.slf4j.Logger; import org.slf4j.LoggerFactory; private static final Logger logger = LoggerFactory.getLogger(MyClass.class);

Conclusion

The article maps out the relationships among Java logging frameworks and provides practical guidance for solving common logging problems, helping developers achieve consistent and maintainable log output.

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.

Javaloggingframeworkslogbackslf4j
ITFLY8 Architecture Home
Written by

ITFLY8 Architecture Home

ITFLY8 Architecture Home - focused on architecture knowledge sharing and exchange, covering project management and product design. Includes large-scale distributed website architecture (high performance, high availability, caching, message queues...), design patterns, architecture patterns, big data, project management (SCRUM, PMP, Prince2), product design, and more.

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.