http://logback.qos.ch/index.html
Logback 是 log4j 作者开发,目前的趋势Log4j逐步被Logback取代。
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-core --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-access</artifactId> <version>1.2.3</version> </dependency> <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency>
package com.logs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyApp { final static Logger logger = LoggerFactory.getLogger("MyApp.class"); public static void main(String[] args) { logger.trace("trace"); logger.debug("debug str"); logger.info("info str"); logger.warn("warn"); logger.error("error"); } }
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。