Skip to content

Commit 1321646

Browse files
committed
Feature to allow suppressing unsuccessful init error message
1 parent 78332e5 commit 1321646

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

slf4j-api/src/main/java/org/slf4j/LoggerFactory.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public final class LoggerFactory {
8181
static final String UNSUCCESSFUL_INIT_URL = CODES_PREFIX + "#unsuccessfulInit";
8282
static final String UNSUCCESSFUL_INIT_MSG = "org.slf4j.LoggerFactory in failed state. Original exception was thrown EARLIER. See also "
8383
+ UNSUCCESSFUL_INIT_URL;
84+
static final String UNSUCCESSFUL_INIT_MSG_SUPPRESSION_SYSTEM_PROPERTY = "slf4j.suppressInitError";
8485

8586
static final int UNINITIALIZED = 0;
8687
static final int ONGOING_INITIALIZATION = 1;
@@ -159,9 +160,12 @@ private final static void bind() {
159160
SUBST_PROVIDER.getSubstituteLoggerFactory().clear();
160161
} else {
161162
INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION;
162-
Util.report("No SLF4J providers were found.");
163-
Util.report("Defaulting to no-operation (NOP) logger implementation");
164-
Util.report("See " + NO_PROVIDERS_URL + " for further details.");
163+
boolean suppressError = Util.safeGetBooleanSystemProperty(UNSUCCESSFUL_INIT_MSG_SUPPRESSION_SYSTEM_PROPERTY);
164+
if (!suppressError) {
165+
Util.report("No SLF4J providers were found.");
166+
Util.report("Defaulting to no-operation (NOP) logger implementation");
167+
Util.report("See " + NO_PROVIDERS_URL + " for further details.");
168+
}
165169

166170
Set<URL> staticLoggerBinderPathSet = findPossibleStaticLoggerBinderPathSet();
167171
reportIgnoredStaticLoggerBinders(staticLoggerBinderPathSet);

0 commit comments

Comments
 (0)