From 8fa52dca1e8f0d88b60b0845fba72bbd00a0cc11 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Mon, 16 Oct 2023 16:22:50 +0200 Subject: [PATCH] Lazy load logger in ResultUtils --- .../main/java/io/qameta/allure/util/ResultsUtils.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java b/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java index 4893dd4d5..7b08825ae 100644 --- a/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java +++ b/allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java @@ -27,7 +27,6 @@ import io.qameta.allure.model.Parameter; import io.qameta.allure.model.Status; import io.qameta.allure.model.StatusDetails; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; @@ -96,7 +95,9 @@ public final class ResultsUtils { public static final String FRAMEWORK_LABEL_NAME = "framework"; public static final String LANGUAGE_LABEL_NAME = "language"; - private static final Logger LOGGER = LoggerFactory.getLogger(ResultsUtils.class); + // We must not initialize the logger here. + // See: https://github.com/allure-framework/allure-java/issues/962 + // private static final Logger LOGGER = LoggerFactory.getLogger(ResultsUtils.class); private static final String ALLURE_DESCRIPTIONS_PACKAGE = "allureDescriptions/"; private static final String MD_5 = "MD5"; @@ -364,7 +365,7 @@ private static String getRealHostName() { try { cachedHost = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { - LOGGER.debug("Could not get host name", e); + LoggerFactory.getLogger(ResultsUtils.class).debug("Could not get host name", e); cachedHost = "default"; } } @@ -407,7 +408,7 @@ private static Optional readResource(final ClassLoader classLoader, fina final byte[] bytes = toBytes(is); return Optional.of(new String(bytes, StandardCharsets.UTF_8)); } catch (IOException e) { - LOGGER.warn("Unable to process description resource file", e); + LoggerFactory.getLogger(ResultsUtils.class).warn("Unable to process description resource file", e); } return Optional.empty(); }