zoukankan      html  css  js  c++  java
  • springboot日志配置

    debug级别

    pom.xml:

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.9</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-core</artifactId>
                <version>1.2.3</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.2.3</version>
            </dependency>

    logback-spring.xml:

    <!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->  
    <configuration scan="true" scanPeriod="10 seconds">  
      <springProperty scope="context" name="logLevel" source="log.level"/>
      <springProperty scope="context" name="logPath" source="log.path"/>
      <!-- Simple file output -->  
      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">  
        <!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->  
        <encoder>  
            <pattern>%d{yy-MM-dd HH:mm:ss.sss} [%thread] %-5level %logger - %X{trackInfo} %msg%n</pattern>  
            <charset>UTF-8</charset> <!-- 此处设置字符集 -->  
        </encoder>  
      
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">  
          <!-- rollover daily 配置日志所生成的目录以及生成文件名的规则 -->  
          <fileNamePattern>${logPath}/log-%d{yyyy-MM-dd}.%i.log</fileNamePattern>  
          <maxHistory>30</maxHistory>
          <timeBasedFileNamingAndTriggeringPolicy  
              class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">  
            <!-- or whenever the file size reaches 64 MB -->  
            <maxFileSize>64 MB</maxFileSize>  
          </timeBasedFileNamingAndTriggeringPolicy>  
        </rollingPolicy>  
      
      
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">  
          <level>DEBUG</level>  
        </filter>  
        <!-- Safely log to the same file from multiple JVMs. Degrades performance! -->  
        <prudent>true</prudent>  
      </appender>  
      
      
      <!-- Console output -->  
      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">  
        <!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->  
          <encoder>  
              <pattern>%d{yy-MM-dd HH:mm:ss.sss} [%thread] %-5level %logger (%file:%line) - %X{trackInfo} %msg%n</pattern>  
              <charset>UTF-8</charset> <!-- 此处设置字符集 -->  
          </encoder>  
        <!-- Only log level WARN and above -->  
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">  
          <level>DEBUG</level>  
        </filter>  
      </appender>  
      
      
      <logger name="jndi" level="WARN" />
       <logger name="org.eclipse" level="WARN" />
      <logger name="org.springframework" level="WARN" />
      <logger name="org.mongodb" level="WARN" />
      <logger name="org.apache" level="WARN" />
      <logger name="com.micropattern.message" level="WARN" />
      <logger name="io.netty" level="WARN" />
      <logger name="org.hibernate" level="WARN" />
      
      <!-- Enable FILE and STDOUT appenders for all log messages.  
           By default, only log at level INFO and above. -->  
      <root level="${logLevel}">  
        <appender-ref ref="FILE" />  
        <appender-ref ref="STDOUT" />  
      </root>  
      
    </configuration>  

    application.yml:

    log:
      path: ../logs
      level: debug
  • 相关阅读:
    Lucene.net系列六 search 下
    Lucene.net 系列三 index 中
    初识Antlr
    Antlr首页计算机器实验成功
    C#语言学习之旅(1):C#基础
    NeatUpload js 判断上传文件的大小是否超过了空间的大小
    对XML的各种操作
    多表求和
    xmlhttp 最简单的无刷新
    xml 查询
  • 原文地址:https://www.cnblogs.com/chong-zuo3322/p/12606211.html
Copyright © 2011-2022 走看看