DEV.co
Open-Source Observability · estk

log4rs

log4rs is a mature, feature-rich logging framework for Rust, inspired by Java's Logback and log4j. It supports YAML/XML configuration, file rotation with optional compression, and runtime log level adjustment.

Source: GitHub — github.com/estk/log4rs
1.1k
GitHub stars
167
Forks
Rust
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryestk/log4rs
Ownerestk
Primary languageRust
LicenseApache-2.0 — OSI-approved
Stars1.1k
Forks167
Open issues48
Latest releasev1.4.0 (2025-09-05)
Last updated2025-11-16
Sourcehttps://github.com/estk/log4rs

What log4rs is

log4rs provides hierarchical logger configuration, multiple appenders (console, file, syslog), pattern-based formatting, and pluggable compression backends. It implements the standard Rust log facade and requires rustc 1.82+.

Quickstart

Get the log4rs source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/estk/log4rs.gitcd log4rs# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Production Rust Services with Complex Logging Requirements

Multi-environment configurations, per-module log levels, and file rotation with compression make log4rs suitable for backend services requiring structured, auditable logging.

Applications Requiring Runtime Log Configuration Changes

The configurable refresh_rate allows live log level adjustments without recompilation, valuable for operational troubleshooting in running systems.

Migrating from Java Logback/log4j Ecosystems

Developers familiar with Logback configuration syntax can leverage similar concepts in log4rs for Rust services, reducing learning curve.

Implementation considerations

  • Choose compression feature strategy early: enable background_rotation if using gzip/zstd to avoid main-thread blocking; alternatively, keep archives small or disable compression.
  • Minimum rustc requirement is 1.82+; verify CI/CD pipelines and development environments meet this baseline.
  • YAML configuration syntax supports hierarchical loggers and additive flags; plan logger hierarchy to match application module structure.
  • Test file rotation and compression behavior under realistic log volume before production deployment, especially if using compression.
  • Dual licensing (Apache-2.0 OR MIT) requires selecting one license path in internal compliance tracking.

When to avoid it — and what to weigh

  • Performance-Critical Paths with File Rotation and Compression — The README explicitly warns of substantial performance issues when gzip/zstd compression occurs on the main thread. Mitigation requires background_rotation feature or archive size constraints.
  • Extremely Minimal Logging Needs — For simple single-appender logging, lighter crates like env_logger or tracing may be more appropriate; log4rs adds complexity for simple use cases.
  • WebAssembly Targets Without Special Configuration — WASM support with time_trigger feature requires explicit Rust compiler flags (--cfg getrandom_backend=wasm_js), adding deployment friction.
  • Rapid Iteration on Unstable APIs — While stable, the project has 48 open issues; active feature development or breaking changes could occasionally require code updates.

License & commercial use

Dual-licensed under Apache License 2.0 and MIT. Both are permissive OSI licenses. Users choose one license for their project; contributors agree to dual licensing without additional terms.

Both Apache-2.0 and MIT are permissive, standard-approved commercial licenses. Commercial use is explicitly permitted under either license. Redistribution, modification, and proprietary use are allowed with license header retention (Apache) or attribution (MIT). No patent grants, royalties, or restrictions apply.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

log4rs itself does not perform cryptographic operations. Security considerations are operational: ensure log files are stored with appropriate access controls to prevent sensitive data leakage. File rotation and compression do not introduce known vulnerabilities but should be tested in your deployment environment. No public security audit data available; review dependencies via cargo audit if high-assurance requirements exist.

Alternatives to consider

env_logger

Simpler, smaller footprint; suitable if hierarchical configuration and file rotation are not needed.

tracing

Modern structured logging framework; preferred for async/tokio-heavy applications and distributed tracing integration.

fern

Programmatic configuration, minimal dependencies; good for simple custom appender needs without YAML configuration overhead.

Software development agency

Build on log4rs with DEV.co software developers

log4rs offers proven configuration patterns from Java ecosystems adapted for Rust. Evaluate its compression trade-offs and feature set against your performance and operational requirements. Our team can guide you through production tuning and integration.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

log4rs FAQ

Does log4rs work in WebAssembly?
Yes, with the time_trigger feature, but requires setting the Rust compiler flag --cfg getrandom_backend=wasm_js. This should be automatic in standard Cargo builds but may require manual setup in some tooling.
Will log4rs block my application during file compression?
Yes, by default, if gzip or zstd compression is enabled. Enable the background_rotation feature to spawn a separate OS thread for compression, preventing main-thread stalls.
Can I change log levels at runtime without restarting?
Yes. Set a refresh_rate in your YAML config (e.g., 30 seconds) to re-read the configuration file periodically and apply log level changes.
Is log4rs suitable for microservices in production?
Yes, if you understand and mitigate the compression performance issue and ensure proper file permissions and disk I/O. It is battle-tested and actively maintained.

Software developers & web developers for hire

Need help beyond evaluating log4rs? DEV.co is a software development agency offering software development services and web development for teams of every size. Our software developers and web developers build custom software, web applications, APIs, and open-source observability integrations — and maintain them long-term.

Ready to implement enterprise-grade logging in Rust?

log4rs offers proven configuration patterns from Java ecosystems adapted for Rust. Evaluate its compression trade-offs and feature set against your performance and operational requirements. Our team can guide you through production tuning and integration.