From c3c07ff1e7fb7749a613d32079dbfd1fcf78d269 Mon Sep 17 00:00:00 2001 From: meowrain Date: Sun, 18 Jan 2026 15:49:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=A0=87=E5=87=86=E5=8C=96?= =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E5=91=BD=E5=90=8D=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将所有微服务名称添加 aioj- 前缀 (auth-service -> aioj-auth-service) - 更新网关路由配置以使用新的服务名称 - 为所有服务添加 logback-spring.xml 日志配置 - 更新 .gitignore 排除 uploads 和 logs 目录 Co-Authored-By: Claude --- .gitignore | 7 +- .../aioj/backend/auth/clients/UserClient.java | 2 +- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application.yml | 7 +- .../src/main/resources/logback-spring.xml | 110 ++++++++++++++++ .../src/main/resources/application.yml | 2 +- .../src/main/resources/logback-spring.xml | 111 ++++++++++++++++ .../src/main/resources/application.yml | 23 ++-- .../src/main/resources/logback-spring.xml | 120 ++++++++++++++++++ .../src/main/resources/application.yml | 7 +- .../src/main/resources/logback-spring.xml | 110 ++++++++++++++++ 11 files changed, 484 insertions(+), 17 deletions(-) create mode 100644 aioj-backend-auth/src/main/resources/logback-spring.xml create mode 100644 aioj-backend-file-service/src/main/resources/logback-spring.xml create mode 100644 aioj-backend-gateway/src/main/resources/logback-spring.xml create mode 100644 aioj-backend-user-service/src/main/resources/logback-spring.xml diff --git a/.gitignore b/.gitignore index 25e5e64..28c791c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,9 @@ build/ ### mybatis plus generator -/generator/ \ No newline at end of file +/generator/ + +### Uploads ### +/uploads/ +### Logs ### +/logs/ \ No newline at end of file diff --git a/aioj-backend-auth/src/main/java/cn/meowrain/aioj/backend/auth/clients/UserClient.java b/aioj-backend-auth/src/main/java/cn/meowrain/aioj/backend/auth/clients/UserClient.java index b0e7c23..5fe0811 100644 --- a/aioj-backend-auth/src/main/java/cn/meowrain/aioj/backend/auth/clients/UserClient.java +++ b/aioj-backend-auth/src/main/java/cn/meowrain/aioj/backend/auth/clients/UserClient.java @@ -6,7 +6,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; -@FeignClient(name = "user-service", path = "/api/v1/user") +@FeignClient(name = "aioj-user-service", path = "/api/v1/user") public interface UserClient { @GetMapping("/inner/get-by-username") diff --git a/aioj-backend-auth/src/main/resources/application-dev.yml b/aioj-backend-auth/src/main/resources/application-dev.yml index 4880e1b..5854faf 100644 --- a/aioj-backend-auth/src/main/resources/application-dev.yml +++ b/aioj-backend-auth/src/main/resources/application-dev.yml @@ -1,6 +1,6 @@ spring: application: - name: auth-service + name: aioj-auth-service data: redis: host: 10.0.0.10 diff --git a/aioj-backend-auth/src/main/resources/application.yml b/aioj-backend-auth/src/main/resources/application.yml index 914ff8a..3ef233c 100644 --- a/aioj-backend-auth/src/main/resources/application.yml +++ b/aioj-backend-auth/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: application: - name: auth-service + name: aioj-auth-service profiles: active: @env@ devtools: @@ -36,4 +36,7 @@ jwt: enabled: true secret: "12345678901234567890123456789012" # 至少32字节!! access-expire: 900000 # 24小时 - refresh-expire: 604800000 # 7天 \ No newline at end of file + refresh-expire: 604800000 # 7天 +logging: + file: + path: ./logs/${spring.application.name} diff --git a/aioj-backend-auth/src/main/resources/logback-spring.xml b/aioj-backend-auth/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..8c32daa --- /dev/null +++ b/aioj-backend-auth/src/main/resources/logback-spring.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + INFO + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + ERROR + ACCEPT + DENY + + + + + + 0 + 512 + + + + 0 + 512 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aioj-backend-file-service/src/main/resources/application.yml b/aioj-backend-file-service/src/main/resources/application.yml index 9860021..17be844 100644 --- a/aioj-backend-file-service/src/main/resources/application.yml +++ b/aioj-backend-file-service/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: application: - name: file-service + name: aioj-file-service profiles: active: @env@ servlet: diff --git a/aioj-backend-file-service/src/main/resources/logback-spring.xml b/aioj-backend-file-service/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..9c5ece5 --- /dev/null +++ b/aioj-backend-file-service/src/main/resources/logback-spring.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + INFO + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + ERROR + ACCEPT + DENY + + + + + + 0 + 512 + + + + 0 + 512 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/aioj-backend-gateway/src/main/resources/application.yml b/aioj-backend-gateway/src/main/resources/application.yml index 78bdf50..f2bc956 100644 --- a/aioj-backend-gateway/src/main/resources/application.yml +++ b/aioj-backend-gateway/src/main/resources/application.yml @@ -2,8 +2,9 @@ server: port: 18085 error: include-stacktrace: never - spring: + application: + name: aioj-backend-gateway profiles: active: @env@ cloud: @@ -13,28 +14,28 @@ spring: routes: # auth服务 Swagger 文档路由 - id: auth-service-doc - uri: lb://auth-service + uri: lb://aioj-auth-service predicates: - Path=/auth-service/** filters: - StripPrefix=1 # user服务 Swagger 文档路由 - id: user-service-doc - uri: lb://user-service + uri: lb://aioj-user-service predicates: - Path=/user-service/** filters: - StripPrefix=1 # auth服务 Swagger 文档路由 - id: file-service-doc - uri: lb://file-service + uri: lb://aioj-file-service predicates: - Path=/file-service/** filters: - StripPrefix=1 - # auth业务接口 + # auth业务接口路由 - id: auth-service - uri: lb://auth-service + uri: lb://aioj-auth-service predicates: - Path=/api/v1/auth/** filters: @@ -46,7 +47,7 @@ spring: firstBackoff: 50ms maxBackoff: 500ms - id: user-service - uri: lb://user-service + uri: lb://aioj-user-service predicates: - Path=/api/v1/user/** filters: @@ -58,7 +59,7 @@ spring: firstBackoff: 50ms maxBackoff: 500ms - id: file-service - uri: lb://file-service + uri: lb://aioj-file-service predicates: - Path=/api/v1/file/** filters: @@ -71,13 +72,14 @@ spring: maxBackoff: 500ms # 文件访问路由(公开,直接转发不去前缀) - id: file-access - uri: lb://file-service + uri: lb://aioj-file-service predicates: - Path=/api/file/** # 设置应用启动后的就绪探针 lifecycle: timeout-per-shutdown-phase: 30s + aioj-backend-gateway: # 白名单配置 white-list: @@ -93,3 +95,6 @@ aioj: log: enabled: true max-length: 20000 +logging: + file: + path: ./logs/${spring.application.name} diff --git a/aioj-backend-gateway/src/main/resources/logback-spring.xml b/aioj-backend-gateway/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..d2eb726 --- /dev/null +++ b/aioj-backend-gateway/src/main/resources/logback-spring.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + INFO + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + ERROR + ACCEPT + DENY + + + + + + 0 + 512 + + + + 0 + 512 + + + + + + + + + + + + + + + + + + + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/auth.log + + ${FILE_LOG_PATTERN} + UTF-8 + + + + + + \ No newline at end of file diff --git a/aioj-backend-user-service/src/main/resources/application.yml b/aioj-backend-user-service/src/main/resources/application.yml index acad1cb..bb01c8f 100644 --- a/aioj-backend-user-service/src/main/resources/application.yml +++ b/aioj-backend-user-service/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: application: - name: user-service + name: aioj-user-service profiles: active: @env@ server: @@ -42,4 +42,7 @@ jwt: aioj: log: enabled: true - max-length: 20000 \ No newline at end of file + max-length: 20000 +logging: + file: + path: ./logs/${spring.application.name} diff --git a/aioj-backend-user-service/src/main/resources/logback-spring.xml b/aioj-backend-user-service/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..8c32daa --- /dev/null +++ b/aioj-backend-user-service/src/main/resources/logback-spring.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/info.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + INFO + + + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.log + + ${LOG_FILE_PATH}/${time-month}/${time-month-day}/error.%d{yyyy-MM-dd}.%i.log.gz + 100MB + 31 + 100GB + + + ${FILE_LOG_PATTERN} + UTF-8 + + + + ERROR + ACCEPT + DENY + + + + + + 0 + 512 + + + + 0 + 512 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file