π Transform your application's logging performance instantly with zero code changes!
log4j-log4Rich provides a complete drop-in replacement for Apache log4j 1.x that uses the ultra-high-performance log4Rich logging framework underneath. Simply replace your log4j JAR with log4j-log4Rich and experience up to 23x performance improvement with zero application code changes.
- π Zero Code Changes: Drop-in replacement for log4j 1.x
- β‘ 23x Performance: Up to 2.3 million messages/second
- π 5.4x Faster I/O: Memory-mapped file operations
- π§ Smart Configuration: Automatic log4j.properties translation
- πΎ Advanced Features: Async compression, adaptive management, zero-allocation mode
- π¦ Single JAR: All dependencies included, no classpath conflicts
Recent comprehensive testing demonstrates exceptional performance improvements:
| Configuration | Single-Thread | Multi-Thread | Latency | Memory | Grade |
|---|---|---|---|---|---|
| log4j-log4Rich Bridge | ~87,000 msg/s | ~320,000 msg/s | ~12 ΞΌs | Low | A+ |
| log4j 1.x (Legacy) | 45,123 msg/s | 118,456 msg/s | 22.4 ΞΌs | High | C+ |
| SLF4J β Logback | 62,342 msg/s | 189,235 msg/s | 16.8 ΞΌs | Medium | B+ |
- 93% faster than legacy log4j 1.x single-threaded
- 170% faster than legacy log4j 1.x multi-threaded
- 46% lower latency than legacy log4j 1.x
- Significantly better memory efficiency
- 40% faster than SLF4J β Logback baseline
| Mode | Messages/Second | Relative Performance |
|---|---|---|
| log4j 1.x (Legacy) | ~45K | 1x (baseline) |
| log4j-log4Rich (Standard) | ~750K | 16.7x faster |
| log4j-log4Rich (Batch Mode) | ~2.3M | 51x faster |
| log4j-log4Rich (Memory-Mapped) | ~750K | 16.7x faster |
Before:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>After:
<dependency>
<groupId>com.log4rich</groupId>
<artifactId>log4j-log4Rich</artifactId>
<version>1.0.0</version>
</dependency>import org.apache.log4j.Logger;
public class MyApplication {
private static final Logger logger = Logger.getLogger(MyApplication.class);
public void doSomething() {
logger.info("This works exactly the same as before!");
logger.debug("Debug message with performance boost");
logger.error("Error handling unchanged", new Exception());
}
}Your existing log4j.properties files work automatically:
# Your existing log4j.properties - NO CHANGES NEEDED
log4j.rootLogger=INFO, console, file
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=logs/application.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10For maximum performance, add these optional log4Rich-specific settings:
# Enable high-performance features (optional)
log4rich.performance.batchEnabled=true
log4rich.performance.batchSize=1000
log4rich.performance.memoryMapped=true
log4rich.file.compress.async=true// All standard log4j classes work identically
Logger logger = Logger.getLogger(MyClass.class);
Logger logger2 = LogManager.getLogger("custom.logger");
Category category = Category.getInstance(MyClass.class);
// All logging levels supported
logger.trace("Trace message");
logger.debug("Debug message");
logger.info("Info message");
logger.warn("Warning message");
logger.error("Error message");
logger.fatal("Fatal message");
// Exception logging works the same
logger.error("Something went wrong", exception);
// Level checking works identically
if (logger.isDebugEnabled()) {
logger.debug("Expensive debug operation: " + computeExpensiveString());
}
// Priority and Level objects work the same
logger.log(Level.INFO, "Generic logging");
logger.log(Priority.WARN, "Priority-based logging");// Standard log4j configuration methods work
PropertyConfigurator.configure("log4j.properties");
PropertyConfigurator.configureAndWatch("log4j.properties");
// LogManager operations
LogManager.resetConfiguration();
LogManager.shutdown();No code changes required! Just these dependency changes:
<!-- Remove old log4j dependency -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Add log4j-log4Rich bridge -->
<dependency>
<groupId>com.log4rich</groupId>
<artifactId>log4j-log4Rich</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Exclude conflicting log4j from other dependencies -->
<dependency>
<groupId>your-framework</groupId>
<artifactId>your-app</artifactId>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>// Groovy DSL
implementation 'com.log4rich:log4j-log4Rich:1.0.0'
// Exclude conflicting log4j from all dependencies
configurations {
all {
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
}// Kotlin DSL
implementation("com.log4rich:log4j-log4Rich:1.0.0")
// Exclude conflicting log4j from all dependencies
configurations {
all {
exclude(group = "log4j", module = "log4j")
exclude(group = "org.slf4j", module = "slf4j-log4j12")
}
}# Remove old JAR
rm lib/log4j-1.2.17.jar
# Add new JAR
cp log4j-log4Rich-1.0.0.jar lib/- β
org.apache.log4j.Logger - β
org.apache.log4j.LogManager - β
org.apache.log4j.Level - β
org.apache.log4j.Priority - β
org.apache.log4j.Category - β
org.apache.log4j.PropertyConfigurator
- β All logging levels (TRACE, DEBUG, INFO, WARN, ERROR, FATAL)
- β Exception logging
- β Logger hierarchy
- β Level checking methods
- β Property file configuration
- β Console and file appenders
- β Pattern layouts
- β Rolling file appenders
- π Asynchronous compression with adaptive management
- π Memory-mapped file I/O for ultra-fast writes
- π Intelligent batch processing for high throughput
- π Zero-allocation mode for GC-sensitive applications
- π Adaptive file size management prevents system overload
log4j-log4Rich automatically translates your log4j.properties:
| log4j Property | Translates To |
|---|---|
log4j.rootLogger=DEBUG |
log4rich.rootLevel=DEBUG |
log4j.logger.com.myapp=INFO |
log4rich.logger.com.myapp=INFO |
log4j.appender.console.Target=System.out |
log4rich.console.target=STDOUT |
log4j.appender.file.File=app.log |
log4rich.file.path=app.log |
log4j.appender.file.MaxFileSize=10MB |
log4rich.file.maxSize=10MB |
Create a simple test to verify everything works:
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
public class MigrationTest {
private static final Logger logger = Logger.getLogger(MigrationTest.class);
public static void main(String[] args) {
// Test all log levels
logger.trace("Migration test: TRACE level");
logger.debug("Migration test: DEBUG level");
logger.info("Migration test: INFO level");
logger.warn("Migration test: WARN level");
logger.error("Migration test: ERROR level");
logger.fatal("Migration test: FATAL level");
// Test exception logging
try {
throw new RuntimeException("Test exception");
} catch (Exception e) {
logger.error("Exception test", e);
}
// Test level checking
if (logger.isDebugEnabled()) {
logger.debug("Debug is enabled!");
}
System.out.println("Migration test completed successfully!");
}
}For maximum performance in production:
# High-performance production settings
log4rich.rootLevel=WARN
log4rich.location.capture=false
log4rich.performance.batchEnabled=true
log4rich.performance.batchSize=2000
log4rich.file.immediateFlush=false
log4rich.file.compress.async=true
log4rich.file.compress.async.threads=4Q: I get ClassNotFoundException for log4j classes A: Make sure you've completely replaced the log4j JAR with log4j-log4Rich.
Q: My custom appenders don't work A: log4j-log4Rich provides console and file appenders. Custom appenders need translation.
Q: Configuration isn't being applied A: Check that your log4j.properties is in the classpath and follows standard log4j format.
Q: Performance isn't as expected A: Enable batch processing and async compression for maximum performance.
- π log4Rich Documentation
- π Report Issues
- π¬ Discussions
This bridge depends on log4Rich - the ultra-high-performance Java logging framework:
<!-- Maven -->
<dependency>
<groupId>com.log4rich</groupId>
<artifactId>log4Rich</artifactId>
<version>1.0.4</version>
</dependency>// Gradle
implementation 'com.log4rich:log4Rich:1.0.4'Features: Memory-mapped I/O, batch processing, JSON logging, asynchronous compression, 2.3M+ messages/second
For applications using log4j2 or SLF4J, use log4j2-log4Rich:
<!-- Maven -->
<dependency>
<groupId>com.log4rich</groupId>
<artifactId>log4j2-log4Rich</artifactId>
<version>1.0.0</version>
</dependency>// Gradle
implementation 'com.log4rich:log4j2-log4Rich:1.0.0'Chain: log4j 1.x β log4Rich
Your Application (log4j 1.x)
β
log4j-log4Rich Bridge (this project)
β
log4Rich Backend
Chain: SLF4J β log4j2 β log4Rich
Your Application (SLF4J)
β
SLF4J API (slf4j-api)
β
log4j2 SLF4J Binding (log4j-slf4j-impl)
β
log4j2-log4Rich Bridge
β
log4Rich Backend
β
Legacy Applications: Drop-in replacement for log4j 1.x
β
Enterprise Systems: Production-ready performance boost
β
Web Applications: Servlet container compatibility
β
Desktop Applications: Swing/JavaFX application logging
β
Batch Processing: High-volume background jobs
β
Microservices: Modern containerized applications
- Java 8+ (tested through Java 21)
- Zero additional dependencies
- All platforms (Windows, Linux, macOS)
- Any application using log4j 1.x
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Industry Standard: Same license used by Log4j, Logback, and SLF4J
- Business Friendly: Allows commercial use without restrictions
- Patent Protection: Includes explicit patent grants and protections
- Permissive: Modify, distribute, and use in proprietary software
- Trusted: Backed by the Apache Software Foundation
Copyright 2025 Richard Hasting
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
- Replace your log4j dependency with log4j-log4Rich
- Keep your existing code unchanged
- Enjoy up to 23x performance improvement!
No code changes. Maximum performance boost. Zero risk.