#log #logger #logging #log4


A highly configurable multi-output logging implementation for the log facade

33 releases (11 breaking)

✓ Uses Rust 2018 edition

0.12.0 May 6, 2020
0.11.0 Mar 11, 2020
0.10.0 Jan 29, 2020
0.9.0 Nov 29, 2019
0.3.1 Mar 26, 2015

#12 in Debugging

Download history 7958/week @ 2020-03-16 7781/week @ 2020-03-23 9097/week @ 2020-03-30 8090/week @ 2020-04-06 8765/week @ 2020-04-13 8473/week @ 2020-04-20 9811/week @ 2020-04-27 9385/week @ 2020-05-04 8775/week @ 2020-05-11 8589/week @ 2020-05-18 8672/week @ 2020-05-25 12343/week @ 2020-06-01 11593/week @ 2020-06-08 9704/week @ 2020-06-15 10827/week @ 2020-06-22 8394/week @ 2020-06-29

35,959 downloads per month
Used in 120 crates (71 directly)


4.5K SLoC


docs crates.io License: MIT OR Apache-2.0 CI Minimum rustc version

log4rs is a highly configurable logging framework modeled after Java's Logback and log4j libraries.


If you are using the file rotation in your configuration there is a known substantial performance issue so listen up! By default the gzip feature is enabled and when rolling files it will zip log archives automatically. This is a problem when the log archives are large as the zip happens in the main thread and will halt the process while the zip is completed. Be advised that the gzip feature will be removed from default features as of 1.0.

The methods to mitigate this are as follows.

  1. Use the background_rotation feature which spawns an os thread to do the compression.
  2. Disable the gzip feature with --no-default-features.
  3. Ensure the archives are small enough that the compression time is acceptable.

For more information see the PR that added background_rotation.

Quick Start


refresh_rate: 30 seconds
    kind: console
    kind: file
    path: "log/requests.log"
      pattern: "{d} - {m}{n}"
  level: warn
    - stdout
    level: info
    level: info
      - requests
    additive: false


use log::{error, info, warn};
use log4rs;

fn main() {
    log4rs::init_file("config/log4rs.yaml", Default::default()).unwrap();

    info!("booting up");

    // ...

Rust Version Requirements

Since version 0.10.0 the minimum version for rust is 1.38.0 and is verified via CI. 1.38.0 is required for windows due to the backtrace crate. 1.34.0 may work for unix environments although it is not officially supported.

Building for Dev

  • Run the tests: cargo test --all-features
  • Run the tests for windows with cross: cross test --target x86_64-pc-windows-gn
  • Run the tests for all individual features: ./test.sh
  • Run the tests for all individual features for windows with cross: ./test.sh win


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.


~22K SLoC