SpringBoot默认日志输出格式

logback.xml



<configuration scan="true" scanPeriod="60 seconds" debug="false">
    
    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>

    
    <property name="log.console_pattern" value="%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
    
    <property name="log.file_pattern" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
    
    <property name="log.dir" value="${catalina.base:-.}/logs"/>
    
    <property name="log.maxHistory" value="30"/>
    
    <property name="project_name" value="${pom.name:-manage}"/>



    
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        
        <encoder>
            <pattern>${log.console_pattern}pattern>
        encoder>
    appender>

    
    
    <appender name="fileAppender"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        

        
        <file>${log.dir}/${project_name}.logfile>
        
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
            <fileNamePattern>${log.dir}/${project_name}-%d{yyyy-MM-dd}.log.gzfileNamePattern>
            
            <maxHistory>${log.maxHistory}maxHistory>
        rollingPolicy>
        
        <encoder>
            <pattern>${log.file_pattern}pattern>
        encoder>
        
        
        
        
        
        
        
        
    appender>

    
    <root level="info">
        <appender-ref ref="fileAppender"/>
        <appender-ref ref="console"/>
    root>
configuration>```

你可能感兴趣的:(spring,boot,logback,xml)