Alternatives
Recipe | Crates | Categories |
---|---|---|
log | ||
slog | ||
log4rs | ||
env_logger | ||
OpenTelemetry | OpenTelemetry Rust documentation⮳ | |
OpenObserve | OpenObserve⮳ |
Use older alternatives to tracing
tracing
is now the "go-to" crate for logging, but log
, slog
and log4rs
are still in extensive use.
log
log
is an older and simpler crate, if your needs are simple and you are not using any async code.
slog
Structured, extensible, composable logging. slog
remains a stable, featureful and battle-tested library, used in many important projects.
fn main() { todo!(); }
log4rs
log4rs
is a highly configurable multi-output logging implementation for the log
facade.
use log::{error, info, warn}; use log4rs; fn main() { log4rs::init_file("config/log4rs.yaml", Default::default()).unwrap(); info!("booting up"); // ... }
env_logger
A logging implementation for log which is configured via an environment variable. env_logger
makes sense when used in executables (binary projects). Libraries should use the log crate instead.
use log::info; fn main() { env_logger::init(); info!("starting up"); // ... }
Other frameworks
OpenTelemetry
OpenTelemetry Rust documentation⮳
fn main() { todo!(); }
OpenObserve
OpenObserve⮳ (written in Rust) is a petabyte-scale Elasticsearch/Splunk/Datadog alternative for logs, metrics, traces, RUM, error tracking, and session replay.
fn main() { todo!(); }