54
54
* <p/>
55
55
* <p/>
56
56
* Please note that all methods in <code>LoggerFactory</code> are static.
57
- *
58
- *
57
+ *
58
+ *
59
59
* @author Alexander Dorokhine
60
60
* @author Robert Elliot
61
61
* @author Ceki Gülcü
62
- *
62
+ *
63
63
*/
64
64
public final class LoggerFactory {
65
65
@@ -75,6 +75,7 @@ public final class LoggerFactory {
75
75
76
76
static final String UNSUCCESSFUL_INIT_URL = CODES_PREFIX + "#unsuccessfulInit" ;
77
77
static final String UNSUCCESSFUL_INIT_MSG = "org.slf4j.LoggerFactory could not be successfully initialized. See also " + UNSUCCESSFUL_INIT_URL ;
78
+ static final String UNSUCCESSFUL_INIT_MSG_SUPPRESSION_SYSTEM_PROPERTY = "slf4j.suppressInitError" ;
78
79
79
80
static final int UNINITIALIZED = 0 ;
80
81
static final int ONGOING_INITIALIZATION = 1 ;
@@ -158,9 +159,12 @@ private final static void bind() {
158
159
String msg = ncde .getMessage ();
159
160
if (messageContainsOrgSlf4jImplStaticLoggerBinder (msg )) {
160
161
INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION ;
161
- Util .report ("Failed to load class \" org.slf4j.impl.StaticLoggerBinder\" ." );
162
- Util .report ("Defaulting to no-operation (NOP) logger implementation" );
163
- Util .report ("See " + NO_STATICLOGGERBINDER_URL + " for further details." );
162
+ boolean suppressError = Util .safeGetBooleanSystemProperty (UNSUCCESSFUL_INIT_MSG_SUPPRESSION_SYSTEM_PROPERTY );
163
+ if (!suppressError ) {
164
+ Util .report ("Failed to load class \" org.slf4j.impl.StaticLoggerBinder\" ." );
165
+ Util .report ("Defaulting to no-operation (NOP) logger implementation" );
166
+ Util .report ("See " + NO_STATICLOGGERBINDER_URL + " for further details." );
167
+ }
164
168
} else {
165
169
failedBinding (ncde );
166
170
throw ncde ;
@@ -319,7 +323,7 @@ private static boolean isAmbiguousStaticLoggerBinderPathSet(Set<URL> binderPathS
319
323
/**
320
324
* Prints a warning message on the console if multiple bindings were found
321
325
* on the class path. No reporting is done otherwise.
322
- *
326
+ *
323
327
*/
324
328
private static void reportMultipleBindingAmbiguity (Set <URL > binderPathSet ) {
325
329
if (isAmbiguousStaticLoggerBinderPathSet (binderPathSet )) {
@@ -348,7 +352,7 @@ private static void reportActualBinding(Set<URL> binderPathSet) {
348
352
/**
349
353
* Return a logger named according to the name parameter using the
350
354
* statically bound {@link ILoggerFactory} instance.
351
- *
355
+ *
352
356
* @param name
353
357
* The name of the logger.
354
358
* @return logger
@@ -361,20 +365,20 @@ public static Logger getLogger(String name) {
361
365
/**
362
366
* Return a logger named corresponding to the class passed as parameter,
363
367
* using the statically bound {@link ILoggerFactory} instance.
364
- *
368
+ *
365
369
* <p>
366
370
* In case the the <code>clazz</code> parameter differs from the name of the
367
371
* caller as computed internally by SLF4J, a logger name mismatch warning
368
372
* will be printed but only if the
369
373
* <code>slf4j.detectLoggerNameMismatch</code> system property is set to
370
374
* true. By default, this property is not set and no warnings will be
371
375
* printed even in case of a logger name mismatch.
372
- *
376
+ *
373
377
* @param clazz
374
378
* the returned logger will be named after clazz
375
379
* @return logger
376
- *
377
- *
380
+ *
381
+ *
378
382
* @see <a
379
383
* href="http://www.slf4j.org/codes.html#loggerNameMismatch">Detected
380
384
* logger name mismatch</a>
@@ -401,7 +405,7 @@ private static boolean nonMatchingClasses(Class<?> clazz, Class<?> autoComputedC
401
405
* <p/>
402
406
* <p/>
403
407
* ILoggerFactory instance is bound with this class at compile time.
404
- *
408
+ *
405
409
* @return the ILoggerFactory instance in use
406
410
*/
407
411
public static ILoggerFactory getILoggerFactory () {
0 commit comments