Skip to content

Commit

Permalink
Avoid duplicated logging when RHBQ is tested on RHEL
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Sep 11, 2024
1 parent f831c7b commit 88bcb8b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions quarkus-test-core/src/main/java/io/quarkus/test/logging/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
Expand All @@ -20,6 +21,7 @@
import org.jboss.logmanager.handlers.ConsoleHandler;
import org.jboss.logmanager.handlers.FileHandler;

import io.quarkus.bootstrap.logging.QuarkusDelayedHandler;
import io.quarkus.test.bootstrap.QuarkusScenarioBootstrap;
import io.quarkus.test.bootstrap.ScenarioContext;
import io.quarkus.test.bootstrap.Service;
Expand Down Expand Up @@ -105,6 +107,17 @@ public static void configure(ScenarioContext scenario) {
Logger logger = LogManager.getLogManager().getLogger("");
logger.setLevel(level);

// Remove existing handlers
for (Handler handler : logger.getHandlers()) {
// we don't need QuarkusDelayedHandler,
// and it leads to log duplication when the 'java.util.logging.manager'
// system property is set to the 'org.jboss.logmanager.LogManager'
if (handler instanceof QuarkusDelayedHandler) {
logger.removeHandler(handler);
break;
}
}

// - Console
ConsoleHandler console = new ConsoleHandler(
ConsoleHandler.Target.SYSTEM_OUT,
Expand Down

0 comments on commit 88bcb8b

Please sign in to comment.