Skip to content

Commit

Permalink
Provide actionable warning when logging level is lower than min level
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 31, 2023
1 parent 68e0f4b commit 9f923e1
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ public ShutdownListener initializeLogging(LogConfig config, LogBuildTimeConfig b
final Logger rootLogger = logContext.getLogger("");

if (config.level.intValue() < buildConfig.minLevel.intValue()) {
log.warnf("Root log level %s set below minimum logging level %s, promoting it to %s",
config.level, buildConfig.minLevel, buildConfig.minLevel);
log.warnf(
"Root log level %s set below minimum logging level %s, promoting it to %s. Set the build time configuration property 'quarkus.log.min-level' to '%s' to avoid this warning",
config.level, buildConfig.minLevel, buildConfig.minLevel, config.level);

rootLogger.setLevel(buildConfig.minLevel);
} else {
Expand Down Expand Up @@ -222,9 +223,10 @@ public void accept(String categoryName, CategoryConfig config) {
CategoryBuildTimeConfig::getMinLevel, categoryDefaultMinLevels, buildConfig.minLevel);

if (logLevel.intValue() < minLogLevel.intValue()) {
log.warnf("Log level %s for category '%s' set below minimum logging level %s, promoting it to %s",
log.warnf(
"Log level %s for category '%s' set below minimum logging level %s, promoting it to %s. Set the build time configuration property 'quarkus.log.category.\"%s\".level' to '%s' to avoid this warning",
logLevel,
categoryName, minLogLevel, minLogLevel);
categoryName, minLogLevel, minLogLevel, categoryName, logLevel);

config.level = InheritableLevel.of(minLogLevel.toString());
}
Expand Down Expand Up @@ -315,8 +317,12 @@ public static void initializeBuildTimeLogging(LogConfig config, LogBuildTimeConf
categoryDefaultMinLevels, buildConfig.minLevel);

if (logLevel.intValue() < minLogLevel.intValue()) {
log.warnf("Log level %s for category '%s' set below minimum logging level %s, promoting it to %s", logLevel,
entry.getKey(), minLogLevel, minLogLevel);
String category = entry.getKey();
log.warnf("Log level %s for category '%s' set below minimum logging level %s, promoting it to %s. "
+
"Set the build time configuration property 'quarkus.log.category.\"%s\".level' to '%s' to avoid this warning",
logLevel,
category, minLogLevel, minLogLevel, category, logLevel);

entry.getValue().level = InheritableLevel.of(minLogLevel.toString());
}
Expand Down

0 comments on commit 9f923e1

Please sign in to comment.