springboot默认日志logback配置

 logging:
    config: classpath:logback-spring.xml

log:
    level: info
    path: ./logs
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class HostNameLogConfig extends ClassicConverter {
    @Override
    public String convert(ILoggingEvent event) {
        try {
            return InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return null;
    }
}
import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class IPLogConfig extends ClassicConverter {

    @Override
    public String convert(ILoggingEvent event) {
        try {
            return InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return null;
    }
}


    
    
    
    
    
    
    
    

    
        
            %green(%hostName %ip -) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger) - %cyan(%msg%n)
        
    

    
        ${logPath}/info.log
        
            INFO
            ACCEPT
            DENY
        
        
            %green(%hostName %ip -) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger) - %cyan(%msg%n)
        
        
            ${logPath}/info.%d{yyyy-MM-dd}.log
            60
        
        
        
            30MB
        
    

    
        ${logPath}/error.log
        
            ERROR
            ACCEPT
            DENY
        
        
            %green(%hostName %ip -) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger) - %cyan(%msg%n)
        
        
            ${logPath}/error.%d{yyyy-MM-dd}.log
            60
        
        
        
            30MB
        
    

    
        
        
        
    

springboot默认日志logback配置_第1张图片
image.png

不带ipLog




    

    
    
    

    
        ${LOG_PATH}/info.log
        
        
            ${LOG_PATH}/info/info-%d{yyyy-MM-dd}.%i.log
            
            
                2MB
            
        
        
        true
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
            UTF-8 
        
        
        
            info
            ACCEPT
            DENY
        
    

    
        ${LOG_PATH}/error.log
        
            ${LOG_PATH}/error/error-%d{yyyy-MM-dd}.%i.log
            
            
                2MB
            
        
        
        true
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
            UTF-8 
        
        
        
            error
            ACCEPT
            DENY
        
    
    
        ${LOG_PATH}/debug.log
        
            ${LOG_PATH}/debug/debug-%d{yyyy-MM-dd}.%i.log
            
            
                2MB
            
        
        
        true
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
            UTF-8 
        
        
        
            debug
            ACCEPT
            DENY
        
    

    
    
        
        ${LOG_PATH}/xinge-message-push_log_warn.log
        
        
            
            ${LOG_PATH}/warn/warn-%d{yyyy-MM-dd}.%i.log
            
            
                2MB
            
        
        
        true
        
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n
            utf-8
        
        
        
            warn
            ACCEPT
            DENY
        
    

    
    
        
        
            [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
            
        
        
        
            DEBUG
        
    
    
    
        
    

    
        
    

    
        
    

    
        
    

    
        
    

    
    
        
        
        
        

        
        
    

你可能感兴趣的:(springboot默认日志logback配置)