API Reference

env_logger

A logging implementation for Rust's log crate configured through environment variables.

Official Documentation ↗
CompatibilityThis documentation covers version v0.11. Check the official docs for the latest API surface.

Installation

cargocargo add env_logger

Methods

env_logger installs a global logger that reads RUST_LOG to set levels and filters.

Key Features

  • Configuration via RUST_LOG
  • Per-module level filters
  • Custom format through Builder

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://docs.rs/env_logger/latest/env_logger/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:25.088Z.

  • Logging of untrusted inputs can cause unexpected behavior as they may include ANSI escape codes which will be forwarded to the users terminal as part of “Weaponizing ANSI Escape Sequences”. (https://docs.rs/env_logger/latest/env_logger/)

FAQ

Why do I see no logs?
RUST_LOG must be set, for example RUST_LOG=info, or a default filter must be configured programmatically.
Can I filter per module?
Yes. RUST_LOG accepts directives such as my_crate=debug,other=warn to set levels per target.
Should I call init twice?
No. The global logger can only be installed once; use try_init and ignore the error in tests.