知乎專欄 | 多維度架構 | | | 微信號 netkiller-ebook | | | QQ群:128659835 請註明“讀者” |
目錄
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"); } }