Several combinations of Log4j log configuration

<div class="iteye-blog-content-contain" style="font-size: 14px"></div>

(Source: http://openwebx.org/docs/logging.html#d0e14854 )

 
commons-logging  apache's original log facade, the purpose is to not rely strongly on the log implementation when developing components, and give the caller a choice.
jcl-over-slf4j  Developed by slf4j to be compatible with the former, the content inside is basically the same as the former, and it is mutually exclusive with the former when referenced.
slf4j- api i    The main api of slf4j, as an independent logging facade.
slf4j-log4j  For the adaptation of slf4j to log4j, log4j log4j should be referenced together with the
log4j  package to implement
logback-classic  logback implementation.
 
Reference relationship:
The log4j references in the current project are confusing. The available dependencies and usage methods are as follows:

 

1. log4j-1.2.16.jar
does not use the framework, only the implementation.
The use of Logger.getLogger() is not often used in the project
 
 

 

2. commons-logging + log4j
simple facade + implementation
use
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
private static final Log logger = LogFactory.getLog(CourseCenterUnitTestBase.class);
 

 

3.  jcl-over-slf4j + slf4j-api + slf4j-log4j + log4j
slf4j facade + log4j implementation.
The official explanation is this combination, which means that the role of jcl-over-slf4j is to graft the facade of apache to the facade of slf4j. I tested it, and actually commons-logging + slf4j-api + slf4j-log4j + log4j seems to work.
Use
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger logger = LoggerFactory.getLogger(CourseCenterUnitTestBase.class);
 
 

 

4. jcl-over-slf4j + slf4j-api + logback-classic
slf4j facade + logback implementation. Haven't used it, I believe there are a lot of them online.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326202266&siteId=291194637