Allow only to specify --log-file

This commit is contained in:
Amos Bird 2022-02-18 18:12:11 +08:00
parent bd2f8958fe
commit 56197cf31e
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4

View File

@ -247,11 +247,8 @@ void Loggers::updateLevels(Poco::Util::AbstractConfiguration & config, Poco::Log
if (log_level > max_log_level) if (log_level > max_log_level)
max_log_level = log_level; max_log_level = log_level;
const auto log_path = config.getString("logger.log", ""); if (log_file)
if (!log_path.empty())
split->setLevel("log", log_level); split->setLevel("log", log_level);
else
split->setLevel("log", 0);
// Set level to console // Set level to console
bool is_daemon = config.getBool("application.runAsDaemon", false); 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); split->setLevel("console", 0);
// Set level to errorlog // Set level to errorlog
int errorlog_level = 0; if (error_log_file)
const auto errorlog_path = config.getString("logger.errorlog", "");
if (!errorlog_path.empty())
{ {
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) if (errorlog_level > max_log_level)
max_log_level = errorlog_level; max_log_level = errorlog_level;
split->setLevel("errorlog", errorlog_level);
} }
split->setLevel("errorlog", errorlog_level);
// Set level to syslog // Set level to syslog
int syslog_level = 0; int syslog_level = 0;