SpringBoot 日志配置logback-spring.xml

application.yml

logging:
  file:
    name: customer_app  # 日志名称
    path: home/  # 日志路径

logback-spring.xml
${LOG_FILE}: customer_app
${LOG_PATH}: home/



<configuration debug="true">

    
    <property name="APP_NAME" value="app-name" />
    
    <property name="LOG_PATH" value="${LOG_PATH}/${APP_NAME}/logs" />
    
    <property name="LOG_FILE" value="${LOG_PATH}/${LOG_FILE}"/>

    
    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        
        <encoder>
            
            
            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} [%line] - %msg%npattern>
            
            <charset>UTF-8charset>
        encoder>
    appender>

    
    
    <appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
        
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} [%line] - %msg%npattern>
            <charset>UTF-8charset>
        encoder>

        
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.logfileNamePattern>
            <maxHistory>15maxHistory>
        rollingPolicy>
    appender>

    <logger name="noModule" level="info"/>
    <logger name="org.codehaus" level="info"/>
    <logger name="org.apache" level="info"/>
    <logger name="org.springframework" level="info"/>
    <logger name="druid.sql" level="info"/>
    <logger name="com.alibaba" level="debug">
        <appender-ref ref="stdout"/>
    logger>
    <logger name="com.baige" level="debug"/>
    <root level="info">
        <appender-ref ref="stdout"/>
        <appender-ref ref="R"/>
    root>
configuration>

你可能感兴趣的:(Spring,Boot,日志)