Simple Logging Facade for Java or (SLF4J) 直译:Java简单日志接口,可以使用开发的人员灵活切换日志框架,例如,log4j、java.util.logger、commons-logging等等。
可以代理的log框架有如图所示这些。
maven:
<dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> <scope>runtime</scope> </dependency> ......使用:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HelloWorld {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(HelloWorld.class);
logger.info("Hello World");
}
}