首页 > 其他 > 详细

LOGBack学习Chapter 1: Introduction

时间:2021-02-13 09:02:54      阅读:31      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/carrothlb/p/14399099.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!