fix: log file

This commit is contained in:
GyDi 2022-03-04 02:04:25 +08:00
parent 4df6571ad9
commit 18f9d6dec5

View File

@ -3,7 +3,7 @@ use chrono::Local;
use log::LevelFilter;
use log4rs::append::console::ConsoleAppender;
use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Config, Logger, Root};
use log4rs::config::{Appender, Config, Root};
use log4rs::encode::pattern::PatternEncoder;
use std::fs;
use std::io::Write;
@ -28,13 +28,11 @@ fn init_log(log_dir: &PathBuf) {
let config = Config::builder()
.appender(Appender::builder().build("stdout", Box::new(stdout)))
.appender(Appender::builder().build("file", Box::new(tofile)))
.logger(
Logger::builder()
.appender("file")
.additive(false)
.build("app", LevelFilter::Info),
.build(
Root::builder()
.appenders(["stdout", "file"])
.build(LevelFilter::Info),
)
.build(Root::builder().appender("stdout").build(LevelFilter::Info))
.unwrap();
log4rs::init_config(config).unwrap();