From 60b89eed259985ac574d17559c3af19b7ea986c1 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Fri, 15 Jan 2021 09:20:39 +0200 Subject: [PATCH] Don't queue up log messages when the process isn't running a Quarkus application Fixes: #14295 --- .../bootstrap/logging/InitialConfigurator.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/InitialConfigurator.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/InitialConfigurator.java index fa062ae8f04bf..e32030c72861c 100644 --- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/InitialConfigurator.java +++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/InitialConfigurator.java @@ -15,6 +15,8 @@ public final class InitialConfigurator implements EmbeddedConfigurator { public static final DelayedHandler DELAYED_HANDLER; + private volatile Boolean isQuarkusApplication = null; + static { //a hack around class loading //this is always loaded in the root class loader with jboss-logmanager, @@ -47,14 +49,24 @@ public Level getLevelOf(final String loggerName) { @Override public Handler[] getHandlersOf(final String loggerName) { + if (isQuarkusApplication == null) { + try { + Class.forName("io.quarkus.runner.ApplicationImpl", false, InitialConfigurator.class.getClassLoader()); + isQuarkusApplication = true; + } catch (ClassNotFoundException e) { + isQuarkusApplication = false; + } + } if (loggerName.isEmpty()) { if (ImageInfo.inImageBuildtimeCode()) { // we can't set a cleanup filter without the build items ready return new Handler[] { createDefaultHandler() }; - } else { + } else if (isQuarkusApplication) { return new Handler[] { DELAYED_HANDLER }; + } else { + return EmbeddedConfigurator.NO_HANDLERS; } } else { return EmbeddedConfigurator.NO_HANDLERS;