• Spring boot:logback文件配置


    resources文件夹下:新建logback-spring.xml文件。

    文件内容like:

    <?xml version="1.0" encoding="UTF-8" ?>
    <configuration>

    <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
    <pattern>
    %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} : %msg%n
    </pattern>
    </layout>

    </appender>

    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <filter class="ch.qos.logback.classic.filter.LevelFilter">
    <level>ERROR</level>
    <onMatch>DENY</onMatch>
    <onMismatch>ACCEPT</onMismatch>
    </filter>
    <encoder>
    <pattern>
    ${FILE_LOG_PATTERN:-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } -- %-40.40logger{39} : %m%n}}
    </pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <fileNamePattern>D:/log/info.%d.log</fileNamePattern>
    </rollingPolicy>
    </appender>

    <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
    <level>ERROR</level>
    </filter>
    <encoder>
    <pattern>
    %msg%n
    </pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <fileNamePattern>D:/log/error.%d.log</fileNamePattern>
    </rollingPolicy>
    </appender>

    <root level="info">
    <appender-ref ref="consoleLog"/>
    <appender-ref ref="fileInfoLog"/>
    <appender-ref ref="fileErrorLog"/>
    </root>

    </configuration>

    详情文档参考:https://wenku.baidu.com/view/71a056eb0975f46527d3e138.html



  • 相关阅读:
    javascript 对象只读
    异步IO
    模板
    Web框架
    WSGI接口
    web开发发展历程
    python函数中的参数类型
    学习网址
    python inspect模块
    详解python的装饰器decorator
  • 原文地址:https://www.cnblogs.com/fqfanqi/p/9536534.html
Copyright © 2020-2023  润新知