From 18f9d6dec5f7a7881fff645d34989930fa69a6bd Mon Sep 17 00:00:00 2001 From: GyDi Date: Fri, 4 Mar 2022 02:04:25 +0800 Subject: [PATCH] fix: log file --- src-tauri/src/utils/init.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/utils/init.rs b/src-tauri/src/utils/init.rs index facb277..885dc34 100644 --- a/src-tauri/src/utils/init.rs +++ b/src-tauri/src/utils/init.rs @@ -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();