2018-11-16-slf4j日志接口配合logback日志组件(xml文件配置方式)

依赖

slf4j-apilogback-classic


    org.slf4j
    slf4j-api
    ${slf4j-version}



    ch.qos.logback
    logback-classic
    ${logback-version}
    
    compile

logback.xml配置示例:

logback官方配置指导https://logback.qos.ch/manual/configuration.html



    
    

    
    

    
    
        
            
            ${LOG_PATTERN}
        
    

    
    
        
            
            ${FILE_PATH}
            
            10MB
            15
            1GB
        
        
            ${LOG_PATTERN}
        
        
    

    
    
        
    

    
    
        
        
    


使用示例:
package test.mylogtest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyLoggerTest {
    private final Logger logger = LoggerFactory.getLogger(MyLoggerTest.class);

    public static void main(String[] args) {
        MyLoggerTest login=new MyLoggerTest();
        login.aVoid();
    }

    public void aVoid() {
        logger.info("Hello World");
    }
}

你可能感兴趣的:(2018-11-16-slf4j日志接口配合logback日志组件(xml文件配置方式))