Java Logging: Automatically default to log4j before slf4j logging if log4j in the classpath, closes #1265.

This commit is contained in:
Shay Banon 2011-08-20 03:27:29 +03:00
parent 779dc4309b
commit a83c45be22
1 changed files with 6 additions and 6 deletions

View File

@ -31,16 +31,16 @@ public abstract class ESLoggerFactory {
private static volatile ESLoggerFactory defaultFactory = new JdkESLoggerFactory(); private static volatile ESLoggerFactory defaultFactory = new JdkESLoggerFactory();
static { static {
try {
Class.forName("org.slf4j.Logger");
defaultFactory = new Slf4jESLoggerFactory();
} catch (Throwable e) {
// no slf4j
try { try {
Class.forName("org.apache.log4j.Logger"); Class.forName("org.apache.log4j.Logger");
defaultFactory = new Log4jESLoggerFactory(); defaultFactory = new Log4jESLoggerFactory();
} catch (Throwable e1) { } catch (Throwable e) {
// no log4j // no log4j
try {
Class.forName("org.slf4j.Logger");
defaultFactory = new Slf4jESLoggerFactory();
} catch (Throwable e1) {
// no slf4j
} }
} }
} }