SpringBoot日志文件logback-spring.xml简析

Springboot日志文件logback-spring.xml简析






<configuration scan="true" scanPeriod="60 seconds" debug="false">
    <contextName>tzzcontextName>
    
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    
    
    <springProperty scope="context" name="springAppName" source="spring.application.name"/>
    
    <property name="LOG_FILE" value="${appHome:-.}/logs/${springAppName}"/>
    
    

    
    <property name="CONSOLE_LOG_PATTERN"
              value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %cyan(${LOG_LEVEL_PATTERN:-%5p}) %red(${PID:- }){magenta} %cyan(${springAppName:---}){faint} [${HOSTNAME}] %clr([%15.15t]){faint} %blue(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
    
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}pattern>
            <charset>utf8charset>
        encoder>
    appender>
    
    <appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_FILE}file>
        
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            
            
            
            <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.gzfileNamePattern>
            
            <maxHistory>7maxHistory>
        rollingPolicy>
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}pattern>
            <charset>utf8charset>
        encoder>
    appender>

    
    <logger name="com.tzz.demo" level="DEBUG" />

    <root level="DEBUG">
        <appender-ref ref="console"/>
        <appender-ref ref="logfile"/>
    root>
configuration>



你可能感兴趣的:(Java基础学习文档,工作中遇到的问题,spring,spring,boot,java)