daboross / fern

Simple, efficient logging for Rust
MIT License
846 stars 51 forks source link

Different formats for differen logging targets? #93

Closed manfredlotz closed 2 years ago

manfredlotz commented 2 years ago

Let's say I log to

        .chain(std::io::stderr())
        .chain(fern::log_file("output.log")?)

How could I define different formats for looging to stderr and file output.log ?

manfredlotz commented 2 years ago

Oops sorry for the noise. I guess I found it as I can do the following

fern::Dispatch::new()
    .format(|out, message, record| {
    ...
    })
    .chain(
        fern::Dispatch::new()
            ...
             .format(|out, message, record| {
    })
    )
    .chain(
        fern::Dispatch::new()
            ...
             .format(|out, message, record| {
    })
    )
    .apply()?;