diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java index 4f4a2ef..f88a54a 100644 --- a/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/src/main/java/org/apache/commons/logging/LogFactory.java @@ -1405,45 +1405,6 @@ public abstract class LogFactory { return newFactory(factoryClass, classLoader, null); } - /** - * Tries to load one of the standard three implementations from the given classloader. - *

- * We assume that {@code classLoader} can load this class. - *

- * @param classLoader The classloader to use. - * @return An implementation of this class. - */ - private static LogFactory newStandardFactory(final ClassLoader classLoader) { - if (isClassAvailable(LOG4J_TO_SLF4J_BRIDGE, classLoader)) { - try { - return (LogFactory) Class.forName(FACTORY_SLF4J, true, classLoader).getConstructor().newInstance(); - } catch (final LinkageError | ReflectiveOperationException ignored) { - } finally { - logDiagnostic( - "[LOOKUP] Log4j API to SLF4J redirection detected. Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J + "'."); - } - } - try { - return (LogFactory) Class.forName(FACTORY_LOG4J_API, true, classLoader).getConstructor().newInstance(); - } catch (final LinkageError | ReflectiveOperationException ignored) { - } finally { - logDiagnostic("[LOOKUP] Loading the Log4j API LogFactory implementation '" + FACTORY_LOG4J_API + "'."); - } - try { - return (LogFactory) Class.forName(FACTORY_SLF4J, true, classLoader).getConstructor().newInstance(); - } catch (final LinkageError | ReflectiveOperationException ignored) { - } finally { - logDiagnostic("[LOOKUP] Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J + "'."); - } - try { - return (LogFactory) Class.forName(FACTORY_DEFAULT, true, classLoader).getConstructor().newInstance(); - } catch (final LinkageError | ReflectiveOperationException ignored) { - } finally { - logDiagnostic("[LOOKUP] Loading the legacy LogFactory implementation '" + FACTORY_DEFAULT + "'."); - } - return null; - } - /** * Gets a new instance of the specified {@code LogFactory} implementation class, loaded by the specified class loader. If that fails, try the class loader * used to load this (abstract) LogFactory. @@ -1500,6 +1461,45 @@ public abstract class LogFactory { return (LogFactory) result; } + /** + * Tries to load one of the standard three implementations from the given classloader. + *

+ * We assume that {@code classLoader} can load this class. + *

+ * @param classLoader The classloader to use. + * @return An implementation of this class. + */ + private static LogFactory newStandardFactory(final ClassLoader classLoader) { + if (isClassAvailable(LOG4J_TO_SLF4J_BRIDGE, classLoader)) { + try { + return (LogFactory) Class.forName(FACTORY_SLF4J, true, classLoader).getConstructor().newInstance(); + } catch (final LinkageError | ReflectiveOperationException ignored) { + } finally { + logDiagnostic( + "[LOOKUP] Log4j API to SLF4J redirection detected. Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J + "'."); + } + } + try { + return (LogFactory) Class.forName(FACTORY_LOG4J_API, true, classLoader).getConstructor().newInstance(); + } catch (final LinkageError | ReflectiveOperationException ignored) { + } finally { + logDiagnostic("[LOOKUP] Loading the Log4j API LogFactory implementation '" + FACTORY_LOG4J_API + "'."); + } + try { + return (LogFactory) Class.forName(FACTORY_SLF4J, true, classLoader).getConstructor().newInstance(); + } catch (final LinkageError | ReflectiveOperationException ignored) { + } finally { + logDiagnostic("[LOOKUP] Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J + "'."); + } + try { + return (LogFactory) Class.forName(FACTORY_DEFAULT, true, classLoader).getConstructor().newInstance(); + } catch (final LinkageError | ReflectiveOperationException ignored) { + } finally { + logDiagnostic("[LOOKUP] Loading the legacy LogFactory implementation '" + FACTORY_DEFAULT + "'."); + } + return null; + } + /** * Returns a string that uniquely identifies the specified object, including * its class.