tracing-subscriber
Utilities for implementing and composing subscribers for Rust's tracing ecosystem. Provides the EnvFilter for RUST_LOG-style level filtering, fmt layer for human-readable or JSON log output, and Registry for layered subscriber composition. The standard way to configure tracing in Rust applications. Works with tracing-opentelemetry for OTel integration.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Log output may contain sensitive data if tracing spans include PII. Filter sensitive fields before logging in production.
⚡ Reliability
Best When
Building production Rust services that need structured logging, distributed tracing, or OpenTelemetry integration.
Avoid When
Simple CLI tools or scripts where env_logger's simplicity is more appropriate.
Use Cases
- • Configure structured JSON logging in Rust production services with tracing_subscriber::fmt().json().init()
- • Set per-crate log levels using RUST_LOG environment variable filtering: RUST_LOG=myapp=debug,hyper=warn
- • Compose multiple tracing layers (fmt + OpenTelemetry + custom) using the layered subscriber architecture
- • Output trace spans as JSON with timing information for structured log aggregation in ELK or Datadog
- • Filter log events by span fields using EnvFilter directives: RUST_LOG='myapp[span{field=value}]=debug'
Not For
- • Simple applications where env_logger suffices — tracing-subscriber has more setup complexity
- • Non-Rust languages — use OpenTelemetry SDKs for other languages
- • High-performance binary log formats — use custom subscribers with binary formats like protobuf for extreme performance
Interface
Authentication
Library — no auth needed.
Pricing
MIT licensed as part of the tokio-rs tracing project.
Agent Metadata
Known Gotchas
- ⚠ tracing_subscriber::fmt().init() can only be called once — use try_init() or set_global_default() for testable initialization that doesn't panic
- ⚠ EnvFilter RUST_LOG directives have a specific syntax — bracket syntax for field filtering: 'myapp[span_name{field=value}]=debug' is different from env_logger
- ⚠ JSON output requires the 'json' feature flag: tracing-subscriber = { features = ['json'] } — not enabled by default
- ⚠ Layer ordering matters in subscriber composition — filters applied to inner layers may not affect outer layers
- ⚠ tracing spans must be entered and exited in LIFO order — using Span::enter() in async code without await inside the guard causes incorrect span attribution
- ⚠ span! and event! macros require the tracing crate as a dependency — tracing-subscriber only provides the configuration, not the instrumentation macros
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for tracing-subscriber.
Scores are editorial opinions as of 2026-03-06.