fix: log file
This commit is contained in:
parent
4df6571ad9
commit
18f9d6dec5
@ -3,7 +3,7 @@ use chrono::Local;
|
|||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use log4rs::append::console::ConsoleAppender;
|
use log4rs::append::console::ConsoleAppender;
|
||||||
use log4rs::append::file::FileAppender;
|
use log4rs::append::file::FileAppender;
|
||||||
use log4rs::config::{Appender, Config, Logger, Root};
|
use log4rs::config::{Appender, Config, Root};
|
||||||
use log4rs::encode::pattern::PatternEncoder;
|
use log4rs::encode::pattern::PatternEncoder;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@ -28,13 +28,11 @@ fn init_log(log_dir: &PathBuf) {
|
|||||||
let config = Config::builder()
|
let config = Config::builder()
|
||||||
.appender(Appender::builder().build("stdout", Box::new(stdout)))
|
.appender(Appender::builder().build("stdout", Box::new(stdout)))
|
||||||
.appender(Appender::builder().build("file", Box::new(tofile)))
|
.appender(Appender::builder().build("file", Box::new(tofile)))
|
||||||
.logger(
|
.build(
|
||||||
Logger::builder()
|
Root::builder()
|
||||||
.appender("file")
|
.appenders(["stdout", "file"])
|
||||||
.additive(false)
|
.build(LevelFilter::Info),
|
||||||
.build("app", LevelFilter::Info),
|
|
||||||
)
|
)
|
||||||
.build(Root::builder().appender("stdout").build(LevelFilter::Info))
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
log4rs::init_config(config).unwrap();
|
log4rs::init_config(config).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user