From 56197cf31e7d7947f9a51fa9512e4c64d67f954f Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Fri, 18 Feb 2022 18:12:11 +0800 Subject: [PATCH] Allow only to specify --log-file --- base/loggers/Loggers.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/base/loggers/Loggers.cpp b/base/loggers/Loggers.cpp index 3c350c834e5..2f2eadea28f 100644 --- a/base/loggers/Loggers.cpp +++ b/base/loggers/Loggers.cpp @@ -247,11 +247,8 @@ void Loggers::updateLevels(Poco::Util::AbstractConfiguration & config, Poco::Log if (log_level > max_log_level) max_log_level = log_level; - const auto log_path = config.getString("logger.log", ""); - if (!log_path.empty()) + if (log_file) split->setLevel("log", log_level); - else - split->setLevel("log", 0); // Set level to console bool is_daemon = config.getBool("application.runAsDaemon", false); @@ -263,15 +260,13 @@ void Loggers::updateLevels(Poco::Util::AbstractConfiguration & config, Poco::Log split->setLevel("console", 0); // Set level to errorlog - int errorlog_level = 0; - const auto errorlog_path = config.getString("logger.errorlog", ""); - if (!errorlog_path.empty()) + if (error_log_file) { - errorlog_level = Poco::Logger::parseLevel(config.getString("logger.errorlog_level", "notice")); + int errorlog_level = Poco::Logger::parseLevel(config.getString("logger.errorlog_level", "notice")); if (errorlog_level > max_log_level) max_log_level = errorlog_level; + split->setLevel("errorlog", errorlog_level); } - split->setLevel("errorlog", errorlog_level); // Set level to syslog int syslog_level = 0;