Auto-detect Log4J2 for logging if on the class-path (#8109)

Motivation:

https://github.com/netty/netty/pull/5047 added Log4J2 support but missed to add code to try to auto-detect it.

Modifications:

Try to use Log4JLoggerFactory by default.

Result:

Fixes https://github.com/netty/netty/issues/8107.
This commit is contained in:
Norman Maurer 2018-07-11 10:19:37 +01:00 committed by GitHub
parent 301e22eafb
commit 93d2807ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,15 +41,20 @@ public abstract class InternalLoggerFactory {
try {
f = new Slf4JLoggerFactory(true);
f.newInstance(name).debug("Using SLF4J as the default logging framework");
} catch (Throwable t1) {
} catch (Throwable ignore1) {
try {
f = Log4JLoggerFactory.INSTANCE;
f.newInstance(name).debug("Using Log4J as the default logging framework");
} catch (Throwable t2) {
} catch (Throwable ignore2) {
try {
f = Log4J2LoggerFactory.INSTANCE;
f.newInstance(name).debug("Using Log4J2 as the default logging framework");
} catch (Throwable ignore3) {
f = JdkLoggerFactory.INSTANCE;
f.newInstance(name).debug("Using java.util.logging as the default logging framework");
}
}
}
return f;
}