4 releases (breaking)

Uses old Rust 2015

0.4.0 Feb 20, 2018
0.3.0 Apr 26, 2017
0.2.0 Feb 14, 2017
0.1.0 Nov 26, 2016

#2 in #appender

MIT/Apache

35KB
783 lines

log4rs-routing-appender

Build Status

Documentation

A routing appender for log4rs.


lib.rs:

A log4rs appender which routes logging events to dynamically created sub-appenders.

For example, you may want to direct output to different directories based on a "job ID" stored in the MDC:

appenders:
  job:
    kind: routing
    router:
      kind: pattern
      pattern:
        kind: file
        path: "log/jobs/${mdc(job_id)}/output.log"
    cache:
      idle_timeout: 30 seconds
loggers:
  server::job_runner:
    appenders:
    - job
#[macro_use]
extern crate log;
extern crate log_mdc;

# fn generate_job_id() -> String { "foobar".to_owned() }
# fn main() {
let job_id = generate_job_id();
log_mdc::insert("job_id", job_id);

info!("Starting job");
# }

Dependencies

~0.5–0.8MB
~16K SLoC