springboot 整合LogBack
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
日誌配置檔案(LogBack ):
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定義日誌檔案的儲存地址 勿在 LogBack 的配置中使用相對路徑-->
<property name="LOG_HOME" value="F:/logs" />
<!-- 控制檯輸出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化輸出:%d表示日期,%thread表示執行緒名,%-5level:級別從左顯示5個字元寬度%msg:日誌訊息,%n是換行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日誌檔案 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日誌檔案輸出的檔名-->
<FileNamePattern>${LOG_HOME}/TestWeb.log.%d{yyyy-MM-dd}.log</FileNamePattern>
<!--日誌檔案保留天數-->
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化輸出:%d表示日期,%thread表示執行緒名,%-5level:級別從左顯示5個字元寬度%msg:日誌訊息,%n是換行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
<!--日誌檔案最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- 日誌輸出級別 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
appliction.yml配置
logging:
config: classpath:logback-spring.xml
啟動專案執行即可
相關文章
- Springboot 整合logback 日誌框架簡介Spring Boot框架
- SpringBoot(三) logback配置Spring Boot
- Spring Boot 整合 Logback 日誌Spring Boot
- SpringBoot之logback配置檔案Spring Boot
- SpringBoot整合系列-整合JPASpring Boot
- 在SpringBoot中使用Logback管理日誌Spring Boot
- 【Java】【SpringBoot】logback開發環境配置JavaSpring Boot開發環境
- springboot專案配置logback日誌系統Spring Boot
- SpringBoot 整合 rabbitmqSpring BootMQ
- SpringBoot 整合 elkSpring Boot
- SpringBoot 整合 elasticsearchSpring BootElasticsearch
- SpringBoot 整合 apolloSpring Boot
- springboot整合redis?Spring BootRedis
- SpringBoot整合RedisSpring BootRedis
- flowable 整合 springbootSpring Boot
- SpringBoot整合MQTTSpring BootMQQT
- ElasticSearch 整合 SpringBootElasticsearchSpring Boot
- SpringBoot整合ESSpring Boot
- Springboot整合pagehelperSpring Boot
- springBoot整合thymeleafSpring Boot
- SpringBoot 整合 RedisSpring BootRedis
- SpringBoot整合NacosSpring Boot
- SpringBoot 整合 dockerSpring BootDocker
- Springboot整合RabbitMQSpring BootMQ
- springBoot整合flowableSpring Boot
- Springboot整合MyabitsSpring Boot
- springBoot 整合 mybatisSpring BootMyBatis
- SpringBoot整合dubboSpring Boot
- SpringBoot整合elasticsearchSpring BootElasticsearch
- RocketMQ整合SpringBootMQSpring Boot
- 【SpringBoot】整合RedisSpring BootRedis
- springboot 整合jeagerSpring Boot
- Springboot整合MybatisSpring BootMyBatis
- SpringBoot(19)---SpringBoot整合ApolloSpring Boot
- SpringBoot(17)---SpringBoot整合RocketMQSpring BootMQ
- SpringBoot(十六)_springboot整合JasperReSpring Boot
- SpringBoot整合系列-整合H2Spring Boot
- SpringBoot整合系列–整合MyBatis-plusSpring BootMyBatis