A lightweight logging facade library for Rust that provides a unified API while allowing flexible backend implementations.
log is a Rust library that provides a lightweight logging facade—a unified API for emitting log messages. It solves the problem of logging interoperability in the Rust ecosystem by allowing libraries to instrument their code without forcing a specific logging implementation on the end user. Applications can then choose from a wide variety of compatible logging backends to handle the actual output.
Rust library authors who need to add logging instrumentation to their crates, and Rust application developers who need to integrate and configure logging across multiple dependencies.
Developers choose log because it is the standard, ecosystem-supported logging facade for Rust, ensuring compatibility across countless libraries and offering maximum flexibility in choosing and switching logging implementations without changing instrumented code.
Logging implementation for Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides standardized macros like `info!` and `warn!` that work across any compatible backend, ensuring consistent logging in libraries and applications as highlighted in the README's usage examples.
Decouples instrumentation from implementation, allowing developers to choose from numerous backends like env_logger or log4rs based on their needs, with over 20 options listed in the README.
With the optional `kv` feature, supports attaching serializable data to logs using serde, Debug, or Display, enabling rich, queryable log records as demonstrated in the structured logging section.
As a foundational crate maintained by rust-lang, it's widely adopted, ensuring compatibility with most Rust libraries and tools, promoting interoperability as per its philosophy.
Implemented with zero-cost abstractions where possible, minimizing overhead and making it suitable for performance-sensitive applications, emphasized in the key features.
Does not output logs by itself; requires initializing a separate backend crate, adding complexity to project setup and an extra dependency management step.
Log messages emitted before the logger is initialized are silently ignored, which can lead to missed diagnostics during early program execution, as warned in the README.
Structured logging via the `kv` feature is not enabled by default, requiring explicit feature activation and potential compatibility issues with some backends.
For full functionality, projects must manage dependencies on both log and a backend, increasing the dependency graph and potential for version conflicts or maintenance overhead.