springBoot log4j,logback的使用

版权声明:帅气Dee海绵宝宝 https://blog.csdn.net/xyjcfucdi128/article/details/84023757

1.log4j

成员变量

//LoginHanderInterceptor  类的名称
private static Logger log=LoggerFactory.getLogger(LoginHanderInterceptor.class);

引用方式(在控制台就可以直接输出 出来log4j)

log.info("log4j");

2.logback

logback是Spring Boot默认的日志系统,假如对日志没有特殊要求,可以完全零配置使用 SLF4J(Simple Logging Facade For Java)的logback来输出日志。

package com.jianeye.test;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
 
SpringBootApplication
public class TestApplication {
 
    private static Logger logger = LoggerFactory.getLogger(TestApplication.class);
 
    public static void main(String[] args) {
        logger.warn("logback --------------------------------\n");  
        SpringApplication.run(TestApplication.class, args);
        logger.info("default log system *************************\n");  
    }
}

猜你喜欢

转载自blog.csdn.net/xyjcfucdi128/article/details/84023757