There is a log in front of a simple introduction of log4j, but also introduced its relationship with commons-logging, but suddenly came out of a slf4j, and SLF4J has replaced the commons-logging trend, so, We can infer that the role of SLF4J and commons-logging should
There is little difference. OK, let's start with slf4j.
1.slf4jHe only provides a core SLF4J API (that is, Slf4j-api.jar package), this package only the log interface, and is not implemented, so if you want to use it will have to give it a implementation of the interface of the log packet, such as: Log4j,common LOGGING,JDK Log logging implementation package, but these log implementations can not be directly called through the interface, the implementation of them at all and slf4j-api inconsistent, so slf4j added a layer to convert the use of the log implementation package, of course, except Slf4j-simple. SLF4J+LOG4J Combined usage mode: 1. Slf4j-api-1.5.11.jar 2. Slf4j-log4j12-1.5.11.jar 3. Log4j-1.2.15.jar 4. Log4j.properties (also can be log4j.xml) jcl+log4j combined usage mode (i.e. commons-logging+log4j): 1. Commons-logging-1.1.jar 2. Log4j-1.2.15.jar 3. Log4j.properties
2. Different ways to get loggerLog4j:import Org.apache.log4j.Logger; Logger logger= Logger.getlogger (xx.class); Slf4j+log4j:import Org.slf4j.logger;import org.slf4j.LoggerFactory; Logger Logger = Loggerfactory.getlogger (Xx.class); Jcl+log4j:import org.apache.commons.logging.log;import org.apache.commons.logging.logfactory;private static log log = Logfactory.getlog (Xx.class);
3. SummaryIn general, SLF4J and commons-logging just a log façade, the actual or to rely on the real log library log4j, although SLF4J and Commons-loggins came with the log library, but after all, log4j is the most powerful.
Http://www.cnblogs.com/zhuawang/p/3999132.html
The relationship between log4j and commons-logging,slf4j (turn)