From c3620c125ec8ccf940a4b095cf7da23771a319ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E6=AD=AA?= Date: Sat, 30 Oct 2021 15:18:25 +0800 Subject: [PATCH] add logback --- .../com/java3y/austin/AustinApplication.java | 6 ++ austin-web/src/main/resources/logback.xml | 81 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 austin-web/src/main/resources/logback.xml diff --git a/austin-web/src/main/java/com/java3y/austin/AustinApplication.java b/austin-web/src/main/java/com/java3y/austin/AustinApplication.java index a8b3949..0fa1253 100644 --- a/austin-web/src/main/java/com/java3y/austin/AustinApplication.java +++ b/austin-web/src/main/java/com/java3y/austin/AustinApplication.java @@ -1,5 +1,7 @@ package com.java3y.austin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.GetMapping; @@ -11,12 +13,16 @@ import org.springframework.web.bind.annotation.RestController; @RestController public class AustinApplication { + private final Logger logger = LoggerFactory.getLogger(AustinApplication.class); + public static void main(String[] args) { SpringApplication.run(AustinApplication.class, args); } @GetMapping("/hello") public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { + logger.error("error logback for austin"); + logger.info("info logback for austin"); return String.format("Hello %s!", name); } diff --git a/austin-web/src/main/resources/logback.xml b/austin-web/src/main/resources/logback.xml new file mode 100644 index 0000000..ef49c0c --- /dev/null +++ b/austin-web/src/main/resources/logback.xml @@ -0,0 +1,81 @@ + + + + + austin + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + UTF-8 + + + + + + + + ${log.path}/austin-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/logs/austin-info-%d{yyyy-MM-dd}.%i.log + + 1000MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/austin-error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/austin-error-%d{yyyy-MM-dd}.%i.log + + 1000MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + \ No newline at end of file