码迷,mamicode.com
首页 > 其他好文 > 详细

LOGBack学习Chapter 1: Introduction

时间:2021-02-16 12:09:06      阅读:0      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!