From 9ff0aaac9cc969c7d4224ce4723f1a8077c854a9 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 27 Apr 2020 21:21:01 +0300 Subject: [PATCH 1/2] Add example of logger.levels usage into config.xml --- programs/server/config.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/programs/server/config.xml b/programs/server/config.xml index 94a2a04e8db..ac62399786b 100644 --- a/programs/server/config.xml +++ b/programs/server/config.xml @@ -11,7 +11,18 @@ 1000M 10 + + + + 8123 9000 From f7673095743f5e912f10d48c078cb017186e69a4 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 27 Apr 2020 21:21:01 +0300 Subject: [PATCH 2/2] Ability to set logger level for loggers that have non allowed in xml tags symbols --- base/loggers/Loggers.cpp | 27 ++++++++++++++++++++++----- programs/server/config.xml | 21 ++++++++++++++++++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/base/loggers/Loggers.cpp b/base/loggers/Loggers.cpp index d5fd4e4e142..ed806741895 100644 --- a/base/loggers/Loggers.cpp +++ b/base/loggers/Loggers.cpp @@ -166,12 +166,29 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log logger.root().setChannel(logger.getChannel()); // Explicitly specified log levels for specific loggers. - Poco::Util::AbstractConfiguration::Keys levels; - config.keys("logger.levels", levels); + { + Poco::Util::AbstractConfiguration::Keys loggers_level; + config.keys("logger.levels", loggers_level); - if (!levels.empty()) - for (const auto & level : levels) - logger.root().get(level).setLevel(config.getString("logger.levels." + level, "trace")); + if (!loggers_level.empty()) + { + for (const auto & key : loggers_level) + { + if (key == "logger" || key.starts_with("logger[")) + { + const std::string name(config.getString("logger.levels." + key + ".name")); + const std::string level(config.getString("logger.levels." + key + ".level")); + logger.root().get(name).setLevel(level); + } + else + { + // Legacy syntax + const std::string level(config.getString("logger.levels." + key, "trace")); + logger.root().get(key).setLevel(level); + } + } + } + } } void Loggers::closeLogs(Poco::Logger & logger) diff --git a/programs/server/config.xml b/programs/server/config.xml index ac62399786b..2162088f1c6 100644 --- a/programs/server/config.xml +++ b/programs/server/config.xml @@ -12,15 +12,34 @@ 10 - + + +