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

cargocargo add log

Methods

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.

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.