improve detection of which logging library to use, use slf4j if its the log4j jar file used (does not have setLevel method)

This commit is contained in:
Shay Banon 2011-12-21 04:27:28 +02:00
parent a488424404
commit ffca91dda0
1 changed files with 3 additions and 1 deletions

View File

@ -32,7 +32,9 @@ public abstract class ESLoggerFactory {
static {
try {
Class.forName("org.apache.log4j.Logger");
Class<?> loggerClazz = Class.forName("org.apache.log4j.Logger");
// below will throw a NoSuchMethod failure with using slf4j log4j bridge
loggerClazz.getMethod("setLevel", Class.forName("org.apache.log4j.Level"));
defaultFactory = new Log4jESLoggerFactory();
} catch (Throwable e) {
// no log4j