Is there anyway to force slf4j to use specific logging provider (logback in my case)? As in their docs:
Multiple bindings were found on the class path
Generally your own code is at the beginning of the classpath. Because of this, one way to do it is to create your own org.slf4j.impl.StaticLoggerBinder class:
package org.slf4j.impl;
import org.slf4j.ILoggerFactory;
import org.slf4j.spi.LoggerFactoryBinder;
/**
* Force tests to use JDK14 for logging.
*/
@SuppressWarnings("UnusedDeclaration")
public class StaticLoggerBinder implements LoggerFactoryBinder {
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
public static String REQUESTED_API_VERSION = "1.6";
public static final StaticLoggerBinder getSingleton() {
return SINGLETON;
}
private StaticLoggerBinder() {
}
@Override
public ILoggerFactory getLoggerFactory() {
return new JDK14LoggerFactory();
}
@Override
public String getLoggerFactoryClassStr() {
return "org.slf4j.impl.JDK14LoggerFactory";
}
}