env_logger (Rust)
Simple, configurable logging backend for Rust's log crate that reads the RUST_LOG environment variable to set log levels per module. The de facto standard for CLI tools and simple applications. Zero-config startup: RUST_LOG=debug cargo run enables debug logging. Formats output to stderr with timestamps and module path.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Logs may contain sensitive data if not carefully managed. RUST_LOG may expose debug info — ensure production RUST_LOG is appropriately restricted.
⚡ Reliability
Best When
Building Rust CLI tools or simple services that need easy log level control via environment variable.
Avoid When
Building production services needing structured logging, distributed tracing, or log aggregation — use tracing instead.
Use Cases
- • Add zero-config debug logging to Rust CLI tools and libraries with RUST_LOG environment variable control
- • Configure per-module log levels for Rust applications: RUST_LOG=myapp=debug,hyper=warn sets different levels per crate
- • Quick prototype logging before switching to tracing or structured logging in production
- • View library debug output from third-party crates that use the log crate
- • Configure custom log formatting and output styling for CLI applications
Not For
- • Structured JSON logging for production services — use tracing + tracing-subscriber with JSON formatter
- • Async-aware distributed tracing — use tokio's tracing ecosystem for spans, context propagation, and OpenTelemetry
- • Log aggregation or shipping — env_logger writes to stderr only; use a log exporter for centralized logging
Interface
Authentication
Library — no auth needed.
Pricing
Open source library.
Agent Metadata
Known Gotchas
- ⚠ Call env_logger::init() only once — calling it twice panics with 'attempted to set a logger after the logging system was already initialized'; use try_init() for safe initialization
- ⚠ RUST_LOG invalid syntax is silently ignored — typos in RUST_LOG filter strings cause all logging to be disabled without error messages
- ⚠ env_logger writes to stderr by default — output goes to stderr, not stdout; redirect appropriately when capturing logs
- ⚠ env_logger does not support structured logging (JSON) — log output is human-readable text; switch to tracing for machine-parseable logs
- ⚠ Log calls in non-main threads are synchronous and blocking — env_logger is not async-aware; heavy logging may cause performance issues in async code
- ⚠ RUST_LOG=target[span{field=value}] filtering syntax requires understanding the tracing_subscriber format — env_logger uses a simpler target=level format only
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for env_logger (Rust).
Scores are editorial opinions as of 2026-03-06.