From 8487c16d9a3c339b2202d7bbc94c37ba6e2bc2df Mon Sep 17 00:00:00 2001 From: Bartosz Spyrko-Smietanko Date: Wed, 4 Sep 2024 16:01:01 +0100 Subject: [PATCH] [#750] Fix logging configuration to avoid duplicated logs when using --debug option --- .../content/bin/prospero-logging.properties | 3 --- .../src/main/java/org/wildfly/prospero/cli/CliMain.java | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dist/common/src/main/resources/packages/org.jboss.prospero/content/bin/prospero-logging.properties b/dist/common/src/main/resources/packages/org.jboss.prospero/content/bin/prospero-logging.properties index dbc829999..c013ab64d 100644 --- a/dist/common/src/main/resources/packages/org.jboss.prospero/content/bin/prospero-logging.properties +++ b/dist/common/src/main/resources/packages/org.jboss.prospero/content/bin/prospero-logging.properties @@ -2,13 +2,10 @@ loggers=org.wildfly.prospero,com.networknt.schema,org.eclipse.aether.internal.impl logger.org.wildfly.prospero.level=INFO -logger.org.wildfly.prospero.handlers=FILE # networknt schema is very verbose at DEBUG level logger.com.networknt.schema.level=INFO -logger.com.networknt.schema.handlers=FILE # set to DEBUG for additional information on artifact resolution logger.org.eclipse.aether.internal.impl.level=INFO -logger.org.eclipse.aether.internal.impl.handlers=FILE # Root logger level logger.level=INFO diff --git a/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliMain.java b/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliMain.java index 7b07049d5..40d2804bf 100644 --- a/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliMain.java +++ b/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliMain.java @@ -115,8 +115,10 @@ public static CommandLine createCommandLine(CliConsole console, String[] args, A if (c instanceof PropertyConfigurator) { LogContextConfiguration lcc = ((PropertyConfigurator) c).getLogContextConfiguration(); lcc.getLoggerConfiguration("org.wildfly.prospero").setLevel(Level.DEBUG.getName()); - lcc.getLoggerConfiguration("org.wildfly.prospero").addHandlerName("CONSOLE"); lcc.getHandlerConfiguration("CONSOLE").setLevel(Level.DEBUG.getName()); + if (!lcc.getLoggerConfiguration("").getHandlerNames().contains("CONSOLE")) { + lcc.getLoggerConfiguration("").addHandlerName("CONSOLE"); + } lcc.commit(); } else { logger.warn("Cannot change logging level, using default.");