Skip to content

Commit 8fa52dc

Browse files
committed
Lazy load logger in ResultUtils
1 parent 2c3ed8b commit 8fa52dc

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

allure-java-commons/src/main/java/io/qameta/allure/util/ResultsUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import io.qameta.allure.model.Parameter;
2828
import io.qameta.allure.model.Status;
2929
import io.qameta.allure.model.StatusDetails;
30-
import org.slf4j.Logger;
3130
import org.slf4j.LoggerFactory;
3231

3332
import java.io.ByteArrayOutputStream;
@@ -96,7 +95,9 @@ public final class ResultsUtils {
9695
public static final String FRAMEWORK_LABEL_NAME = "framework";
9796
public static final String LANGUAGE_LABEL_NAME = "language";
9897

99-
private static final Logger LOGGER = LoggerFactory.getLogger(ResultsUtils.class);
98+
// We must not initialize the logger here.
99+
// See: https://github.com/allure-framework/allure-java/issues/962
100+
// private static final Logger LOGGER = LoggerFactory.getLogger(ResultsUtils.class);
100101
private static final String ALLURE_DESCRIPTIONS_PACKAGE = "allureDescriptions/";
101102
private static final String MD_5 = "MD5";
102103

@@ -364,7 +365,7 @@ private static String getRealHostName() {
364365
try {
365366
cachedHost = InetAddress.getLocalHost().getHostName();
366367
} catch (UnknownHostException e) {
367-
LOGGER.debug("Could not get host name", e);
368+
LoggerFactory.getLogger(ResultsUtils.class).debug("Could not get host name", e);
368369
cachedHost = "default";
369370
}
370371
}
@@ -407,7 +408,7 @@ private static Optional<String> readResource(final ClassLoader classLoader, fina
407408
final byte[] bytes = toBytes(is);
408409
return Optional.of(new String(bytes, StandardCharsets.UTF_8));
409410
} catch (IOException e) {
410-
LOGGER.warn("Unable to process description resource file", e);
411+
LoggerFactory.getLogger(ResultsUtils.class).warn("Unable to process description resource file", e);
411412
}
412413
return Optional.empty();
413414
}

0 commit comments

Comments
 (0)