From c3a6f85c760dfd443a7ee5981ba06fdee7929bae Mon Sep 17 00:00:00 2001 From: qinyingjie Date: Mon, 19 Dec 2022 17:51:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserController.java | 3 + src/main/resources/application.yaml | 6 +- src/main/resources/logback-spring.xml | 69 +++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/logback-spring.xml diff --git a/src/main/java/com/kwan/springbootkwan/controller/UserController.java b/src/main/java/com/kwan/springbootkwan/controller/UserController.java index 1d43e7e..65e944e 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/UserController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/UserController.java @@ -4,6 +4,7 @@ import com.kwan.springbootkwan.entity.User; import com.kwan.springbootkwan.service.IUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -16,6 +17,7 @@ import java.util.List; * @version : 2.2.0 * @date : 2022/12/19 16:08 */ +@Slf4j @Api(description = "用户信息", tags = "UserController") @RestController @RequestMapping("/user") @@ -27,6 +29,7 @@ public class UserController { @ApiOperation(value = "获取所有用户", notes = "获取所有用户") @RequestMapping(value = "/all", method = RequestMethod.GET) public List addAdvertise() { + log.info("测试日志={}", "success"); return userService.getUsers(); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b8c6909..eafea58 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -43,4 +43,8 @@ mybatis-plus: logic-delete-field: delFlag logic-delete-value: 1 logic-not-delete-value: 0 - table-underline: true \ No newline at end of file + table-underline: true + +#logger配置 +logging: + config: classpath:logback-spring.xml \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..86327aa --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + ../logs/springboot-mybatis.log + + + %date [%level] [%thread] %logger{60} [%file : %line] %msg%n + + UTF-8 + + + + + ../logs/springboot-mybatis.log.%d{yyyy-MM-dd}.log + + 30 + + 10GB + + + + + + + ../logs/error.log + + %date [%level] [%thread] %logger{60} [%file : %line] %msg%n + + UTF-8 + + + + + ../logs/error.%d{yyyy-MM-dd}.log + + 30 + + 10GB + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + \ No newline at end of file -- GitLab