Slf4j Log Selection Policy

  mongodb, question

I configured slf4j and morphia in the project.

 <!  -- slf4j dependency->

The log configuration is as follows

private static Logger logger = LoggerFactory.getLogger(MongodbTest.class);
 * List all database names
 public void testSlf4j(){

The following is the output information

April 23, 2018 3:59:18 p.m. org.mongodb.morphia.logging.morphialoggerfactory chooseloggerfactory
 Information: loggerimplfactoryset to org.mongodb.morphia.logging.jdk.jdkloggerfactory
 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [springconfig.xml]
 [main]   INFO - Refreshing startup date [Mon Apr 23 15:59:19 CST 2018];  root of context hierarchy
 [main] WARN shenzhen.MongodbTest - lalala
 [main] INFO shenzhen.MongodbTest - lalala

Why did slf4j choose morphia’s log instead of slf4j’s simple log

If you want to use slf4j’s log module and introduce org.mongodb.morphia, you should exclude its log part.
The reason for this phenomenon is that when log found the implementation class, it first found mongodb’s log implementation class and instantiated it.
Maven configuration reference exclusion:

 <groupId> XXXXXX </groupId>
 <artifactId> XXXXXX </artifactId>