From Rust Community Wiki

All user facing applications should display information to the user whether it's information to warn them of a minor failure, display application breaking errors, or displaying debugging information. The Rust crate ecosystem has many different types of logging crates that can help.

Log level[edit]

The log level also known as the maximum log level, for a logging application dictates the displayed level of messages for the current runtime of an application. The maximum log level is represented internally as an unsigned integer value or enumeration corresponding to the level of output, all log levels below the set maximum value are enabled.

Name Description Value
Trace Verbose descriptive information regarding the inner workings of the application 6
Debug Descriptive information useful for debugging the application 5
Info Informational messages that highlight the progress of the application 4
Warn Information regarding a non-breaking potentially harmful situation 3
Error An application error that is recoverable 2
Critical An application terminating situation 1
Off Don't display any logging information 0


Majority of Rust crates for logging are implementations of Cargo vec.svglog , which exposes 5 Macros that are used similarly to println!This links to official Rust documentation.

A logging implementation must be used otherwise Log falls back to a "noop" implementation that ignores all log messages.

Implementation comparisons[edit]

Comparison table columns have the following meaning:

  • Color: Log levels are displayed in color when logging to a terminal
  • File: Ability to log to a file in addition to standard output and standard error
  • Custom Format: Ability to format logging messages in any form
  • Module: Ability to change the logging level based on modules or crates
  • Environment: Logger can use environment variables to set the level of logging
Name Color File Custom Format Module Environment Note
Cargo vec.svgenv_logger yes no yes no yes Created by the Rust Team for use in Cargo vec.svgCargo
Cargo vec.svgpretty_env_logger yes no yes no yes Wrapper around Cargo vec.svgenv_logger
Cargo vec.svgsimplelog yes yes partial yes no Components of message are optional, but can't be rearranged
Cargo vec.svgstderrlog yes no no yes no
Cargo vec.svgflexi_logger yes yes yes yes yes Rotates log files
Cargo vec.svgsimple_logger yes no no no yes Colors are fixed for log levels
Cargo vec.svgsimple-logging no yes no no no Log to arbitrary sink
Cargo vec.svglog-derive yes no no no no Attribute macros for logging function invocations. Wrapper around Cargo vec.svgsimplelog
Cargo vec.svgfern yes yes yes yes no Rotates log files based on date