Use spring boot's own log

spring boot starter version 2.7.8

This version comes with slf4j-api

It contains other packages of logback-classic logback

You can use slf4j directly

However, the configured log output to the file cannot take effect normally.

Official website description:

Spring Boot Reference Documentation

All internal logs of springboot use common logging output, but the specific log implementation is not limited.

By default, springboot only outputs logs to the console and does not write to log files. Logs can be written to files by configuring the logging.file.name and
logging.file.path properties (for example, in the application.properties file).

But this has a premise, you still have to rely on other log jar packages, such as directly importing spring-boot-starter-logging directly, to generate log file directories normally

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-logging</artifactId>
</dependency>

In the configuration, only one of file.path and file.name will take effect and cannot be set at the same time Source code

If only path is set, spring.log file will be generated by default

 

Guess you like

Origin blog.csdn.net/wdd668/article/details/129177508