标签:slf4j jar包 str apach core root pack log4 chapter
1、Hello LOGBack代码
jar包:slf4j-api-1.7.30.jar,logback-classic-1.2.3.jar,logback-core-1.2.3.jar
package main; //import org.apache.log4j.Logger; //import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.core.util.StatusPrinter; import main.test.Test; public class Main { public static void main(String[] args) { //SLF4J中的logger不能设置level ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); //Logger logger = Logger.getLogger("com.foo"); logger.setLevel(Level.TRACE); logger.trace("trace"); logger.debug("debug"); logger.info("Hello World"); logger.warn("wrain"); logger.error("error"); Test t=new Test(); t.test(); // print internal state LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); StatusPrinter.print(lc); } }
LOGBack学习Chapter 1: Introduction
标签:slf4j jar包 str apach core root pack log4 chapter
原文地址:https://www.cnblogs.com/carrothlb/p/14399099.html