Support Log framework: Java Util Logging, log4j2 and Logback, using Logback by default
How to configure: Default profile configuration and reference external configuration file configuration
First, the default configuration file configuration (not recommended: not flexible, log4j2, etc. is not friendly)
# log file name, for example: Roncoo.log, or/var/log/roncoo.log
Logging.file=roncoo.log
# Log level configuration, for example: Logging.level.org.springframework=debug
Logging.level.*=info
Logging.level.org.springframework=debug
Second, reference external configuration file
2.1logback Configuration method:
Spring boot will load Classpath:logback-spring.xml or Classpath:logback-spring.groovy by default
Use a custom configuration file, configured as follows:
Logging.config=classpath:logback-roncoo.xml
Note: Do not use Logback to name this, otherwise spring boot will not be fully instantiated
1. Using spring boot-based configuration
<?xml version= "1.0" encoding= "UTF-8"?>
<configuration>
<include resource= "Org/springframework/boot/logging/logback/base.xml"/>
<logger name= "Org.springframework.web" level= "DEBUG"/>
</configuration>
2. Custom Configuration
See nearby
2.2LOG4J Configuration
2.2.1 Remove Logback Dependency package, add log4j2 dependency Package
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
<!--using Log4j2--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
2.2.2 Add Log4j2.xml or Log4j2-spring.xml in classpath (Spring boot default load)
2.3 Custom configuration Files
See annex
Three Comparison
Performance comparison: Log4j2 and Logback are better than log4j (deprecated)
Configuration: Logback The most concise, spring boot default, recommended to use
Example code:
Spring Boot Learning (log configuration)