It would seem a fairly fundamental use case to simply log to a file.
I tried a simple example via setting the target of the builder as a file:
use env_logger::{fmt::Target, Builder};
use log::error;
fn main() {
let file = std::fs::OpenOptions::new()
.create(true)
.append(true)
.open("log.txt")
.unwrap();
let mut builder = Builder::from_default_env();
builder.target(Target::Pipe(Box::new(file))).init();
error!("Some error");
}
But this seems to have had no affect other than implicitly doing builder.write_style(WriteStyle::Never); with the output still being written to the console.
It would seem a fairly fundamental use case to simply log to a file.
I tried a simple example via setting the target of the builder as a file:
But this seems to have had no affect other than implicitly doing
builder.write_style(WriteStyle::Never);
with the output still being written to the console.Is there any example of logging to a file?