API Reference
log
A lightweight logging facade for Rust that libraries use to emit logs without choosing a backend.
Official Documentation ↗CompatibilityThis documentation covers version
v0.4. Check the official docs for the latest API surface.Installation
cargo
cargo add logMethods
No methods match this filter.
log defines macros and traits; an implementation such as env_logger or tracing wires them up.
Key Features
- Level macros from error to trace
- Backend-agnostic facade
- Static max level for cheap checks
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://docs.rs/log/latest/log/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:43.386Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- Parse Level Error The type returned by from_str when the string doesn’t match any of the log levels. (https://docs.rs/log/latest/log/)
- SetLogger Error The type returned by set_logger if set_logger has already been called. (https://docs.rs/log/latest/log/)
FAQ
- Why are my logs not appearing?
- log is only a facade. Install an implementation such as env_logger or a tracing subscriber to see output.
- Does the log macro evaluate arguments when disabled?
- No. The macro checks the level and, when filtered out, skips argument formatting entirely.
- Should libraries pick a backend?
- No. Libraries should only depend on log; the application decides which implementation to install.
Report a problem with this API docOpens a pre-filled issue on GitHub.