SLF4J logging interface framework
introduce
SLF4J, the Simple Logging Facade for Java, is not a specific logging solution, it only serves a variety of logging systems. Officially, SLF4J is a simple facade for logging systems, allowing end users to deploy their applications with the logging system they want
Instructions for use
Dependency package: slf4j-api, slf4j-jdk14/slf4j-simple
use
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
</dependency>
code
public class TestLog {
private static Logger LOG = LoggerFactory.getLogger(TestLog.class);
public TestLog() {
}
public static void main(String[] args) {
LOG.error("Error Message!");
LOG.warn("Warn Message!");
LOG.info("Info Message!");
LOG.debug("Debug Message!");
LOG.trace("Trace Message!");
}
}
output
四月 18, 2018 3:17:08 下午 com.gdunis.logger.TestLog main
严重: Error Message!
四月 18, 2018 3:17:08 下午 com.gdunis.logger.TestLog main
警告: Warn Message!
四月 18, 2018 3:17:08 下午 com.gdunis.logger.TestLog main
信息: Info Message!