From 6f08f07477367ba14030fbb24de68b20bee762d9 Mon Sep 17 00:00:00 2001 From: Romain QUINIO Date: Fri, 17 Jan 2025 16:50:04 +0100 Subject: [PATCH] fix: do not check categories without named handlers --- .../runtime/logging/LoggingSetupRecorder.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java index 3d8fe47a07940..d6ea4794e6b20 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java @@ -261,7 +261,8 @@ public void close() throws SecurityException { namedHandlers.putAll(additionalNamedHandlersMap); - setUpCategoryLoggers(buildConfig, categoryDefaultMinLevels, categories, logContext, errorManager, namedHandlers); + setUpCategoryLoggers(buildConfig, categoryDefaultMinLevels, categories, logContext, errorManager, namedHandlers, + true); } for (RuntimeValue> additionalHandler : additionalHandlers) { @@ -344,7 +345,7 @@ public static void initializeBuildTimeLogging( emptyList(), emptyList(), emptyList(), emptyList(), errorManager, logCleanupFilter, emptyMap(), launchMode, dummy, false); - setUpCategoryLoggers(buildConfig, categoryDefaultMinLevels, categories, logContext, errorManager, namedHandlers); + setUpCategoryLoggers(buildConfig, categoryDefaultMinLevels, categories, logContext, errorManager, namedHandlers, false); addNamedHandlersToRootHandlers(config.handlers(), namedHandlers, handlers, errorManager); InitialConfigurator.DELAYED_HANDLER.setAutoFlush(false); @@ -482,7 +483,8 @@ public void run() { private static void addNamedHandlersToCategory( CategoryConfig categoryConfig, Map namedHandlers, Logger categoryLogger, - ErrorManager errorManager) { + ErrorManager errorManager, + boolean checkHandlerLinks) { for (String categoryNamedHandler : categoryConfig.handlers().get()) { Handler handler = namedHandlers.get(categoryNamedHandler); if (handler != null) { @@ -493,7 +495,7 @@ public void run() { categoryLogger.removeHandler(handler); } }); - } else { + } else if (checkHandlerLinks) { errorManager.error(String.format("Handler with name '%s' is linked to a category but not configured.", categoryNamedHandler), null, ErrorManager.GENERIC_FAILURE); } @@ -506,7 +508,8 @@ private static void setUpCategoryLoggers( final Map categories, final LogContext logContext, final ErrorManager errorManager, - final Map namedHandlers) { + final Map namedHandlers, + final boolean checkHandlerLinks) { for (Entry entry : categories.entrySet()) { String categoryName = entry.getKey(); @@ -532,7 +535,7 @@ private static void setUpCategoryLoggers( } categoryLogger.setUseParentHandlers(categoryConfig.useParentHandlers()); if (categoryConfig.handlers().isPresent()) { - addNamedHandlersToCategory(categoryConfig, namedHandlers, categoryLogger, errorManager); + addNamedHandlersToCategory(categoryConfig, namedHandlers, categoryLogger, errorManager, checkHandlerLinks); } } }