zoukankan      html  css  js  c++  java
  • logback日志配置文件

    application.properties

    application.properties

    logback-spring.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <!-- 定义log文件的目录 -->
      <property name="LOG_HOME" value="log"></property>
      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
          <!-- %.-1level 只显示信息级别的首字母,%-5level 左对齐显示信息级别全称 -->
          <Pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</Pattern>
        </encoder>
      </appender>
      <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/trace.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
          <fileNamePattern>${LOG_HOME}/logs/trace.%d{yyyy-MM-ddssSSS}.%i.log.zip</fileNamePattern>
          <maxFileSize>20MB</maxFileSize>
          <maxHistory>7</maxHistory>
          <totalSizeCap>20GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
          <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
          <level>TRACE</level>
          <onMatch>ACCEPT</onMatch>
          <onMismatch>DENY</onMismatch>
        </filter>
      </appender>
      <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/info.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
          <fileNamePattern>${LOG_HOME}/logs/info.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
          <maxFileSize>20MB</maxFileSize>
          <maxHistory>7</maxHistory>
          <totalSizeCap>20GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
          <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
          <level>INFO</level>
          <onMatch>ACCEPT</onMatch>
          <onMismatch>DENY</onMismatch>
        </filter>
      </appender>
      <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/debug.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
          <fileNamePattern>${LOG_HOME}/logs/debug.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
          <maxFileSize>20MB</maxFileSize>
          <maxHistory>7</maxHistory>
          <totalSizeCap>20GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
          <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
          <level>DEBUG</level>
          <onMatch>ACCEPT</onMatch>
          <onMismatch>DENY</onMismatch>
        </filter>
      </appender>
      <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/warn.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
          <fileNamePattern>${LOG_HOME}/logs/warn.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
          <maxFileSize>20MB</maxFileSize>
          <maxHistory>7</maxHistory>
          <totalSizeCap>20GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
          <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
          <level>WARN</level>
          <onMatch>ACCEPT</onMatch>
          <onMismatch>DENY</onMismatch>
        </filter>
      </appender>
      <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/error.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
          <fileNamePattern>${LOG_HOME}/logs/error.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
          <maxFileSize>20MB</maxFileSize>
          <maxHistory>7</maxHistory>
          <totalSizeCap>20GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
          <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
          <level>ERROR</level>
          <onMatch>ACCEPT</onMatch>
          <onMismatch>DENY</onMismatch>
        </filter>
      </appender>
      <appender name="ALL_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_HOME}/all.log</file>
        <append>true</append>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
          <fileNamePattern>${LOG_HOME}/logs/all.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
          <maxFileSize>100MB</maxFileSize>
          <maxHistory>7</maxHistory>
          <totalSizeCap>50GB</totalSizeCap>
        </rollingPolicy>
        <encoder>
          <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line] --%mdc{client} %msg%n</pattern>
        </encoder>
      </appender>
      <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="TRACE_FILE" />
        <appender-ref ref="INFO_FILE" />
        <appender-ref ref="DEBUG_FILE" />
        <appender-ref ref="WARN_FILE" />
        <appender-ref ref="ERROR_FILE" />
        <appender-ref ref="ALL_FILE" />
      </root>
    </configuration>
    人生如修仙,岂是一日间。何时登临顶,上善若水前。
  • 相关阅读:
    Mysql存储引擎
    k8s集群故障二:节点为NotReady状态
    K8S集群二进制搭建3——部署Master Node
    K8S集群二进制搭建2——docker搭建
    K8S集群二进制搭建1——集群介绍及Etcd集群搭建
    政府会计
    其他收益、递延收益的区别
    未确认融资费用通俗理解
    非货币性资产交换的会计处理
    借营业收入贷营业成本投资收益
  • 原文地址:https://www.cnblogs.com/f-society/p/11083426.html
Copyright © 2011-2022 走看看