参考:https://blog.csdn.net/AIJXB/article/details/128602818
pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency>
application.yaml配置
logging: level: root: INFO file: name: sys.log logback: rollingpolicy: # gz file-name-pattern: ${LOG_FILE}.%d{yyyy-MM-dd}.%i.zip max-file-size: 1MB pattern: dateformat: yyyy-MM-dd HH:mm:ss
示例
package com.xcg.webapp.Controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/Test") public class TestController { private static final Logger logger = LoggerFactory.getLogger(TestController.class); @GetMapping("/writeLog") public String writeLog() { logger.info("this is a test message!"); System.out.println(logger.getClass().toString()); //class ch.qos.logback.classic.Logger return "welcome to spring boot3"; } }
标签:web,springframework,class,SpringBoot3,import,org,日志,Logback,logger From: https://www.cnblogs.com/xsj1989/p/18152407