From e2e73dffdaaf9aae531a1cef85fb92a2ed78e2b2 Mon Sep 17 00:00:00 2001 From: PIG AI Date: Wed, 25 Jun 2025 16:53:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(register):=20=E6=B7=BB=E5=8A=A0logback?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=85=8D=E7=BD=AE=E5=B9=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?nacos=E6=97=A5=E5=BF=97=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增logback-spring.xml配置文件用于日志管理 - 设置nacos相关日志级别为OFF以减少干扰 - 配置console和file两种日志输出方式 - 在PigxNacosApplication中指定日志配置文件路径 --- .../nacos/bootstrap/PigxNacosApplication.java | 4 + .../src/main/resources/logback-spring.xml | 94 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 pigx-register/src/main/resources/logback-spring.xml diff --git a/pigx-register/src/main/java/com/alibaba/nacos/bootstrap/PigxNacosApplication.java b/pigx-register/src/main/java/com/alibaba/nacos/bootstrap/PigxNacosApplication.java index c7a7e3ebe..0c0c36412 100644 --- a/pigx-register/src/main/java/com/alibaba/nacos/bootstrap/PigxNacosApplication.java +++ b/pigx-register/src/main/java/com/alibaba/nacos/bootstrap/PigxNacosApplication.java @@ -12,6 +12,9 @@ import org.springframework.boot.WebApplicationType; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; +import static org.springframework.boot.context.logging.LoggingApplicationListener.CONFIG_PROPERTY; +import static org.springframework.core.io.ResourceLoader.CLASSPATH_URL_PREFIX; + /** * @author nacos *

@@ -26,6 +29,7 @@ public class PigxNacosApplication { public static void main(String[] args) { System.setProperty(STANDALONE_MODE, "true"); + System.setProperty(CONFIG_PROPERTY, CLASSPATH_URL_PREFIX + "logback-spring.xml"); String type = System.getProperty(Constants.NACOS_DEPLOYMENT_TYPE, Constants.NACOS_DEPLOYMENT_TYPE_MERGED); DeploymentType deploymentType = DeploymentType.getType(type); diff --git a/pigx-register/src/main/resources/logback-spring.xml b/pigx-register/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..a1931d8b7 --- /dev/null +++ b/pigx-register/src/main/resources/logback-spring.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + ${log.path}/debug.log + + ${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + + + + ${log.path}/error.log + + ${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz + 50MB + 30 + + + %date [%thread] %-5level [%logger{50}] %file:%line - %msg%n + + + ERROR + + + + + + + + + + + + + + + + + + + + + + + +