From 6197254ea2061d9f5c00aa003765a9ae2498f441 Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 4 Nov 2019 11:21:11 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=20=E5=A2=9E=E5=8A=A0elk=E9=9B=86?= =?UTF-8?q?=E6=88=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/CommonConstant.java | 32 +++++++++++++++++++ .../common/launch/LauncherServiceImpl.java | 2 ++ 2 files changed, 34 insertions(+) diff --git a/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java b/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java index 203a2318..fc664b4a 100644 --- a/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java +++ b/blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java @@ -70,6 +70,21 @@ public interface CommonConstant { */ String ZIPKIN_TEST_ADDR = "http://172.30.0.58:9411"; + /** + * elk dev 地址 + */ + String ELK_DEV_ADDR = "127.0.0.1:9000"; + + /** + * elk prod 地址 + */ + String ELK_PROD_ADDR = "172.30.0.58:9000"; + + /** + * elk test 地址 + */ + String ELK_TEST_ADDR = "172.30.0.58:9000"; + /** * sword 系统名 */ @@ -156,4 +171,21 @@ public interface CommonConstant { } } + /** + * 动态获取elk地址 + * + * @param profile 环境变量 + * @return addr + */ + static String elkAddr(String profile) { + switch (profile) { + case (AppConstant.PROD_CODE): + return ELK_PROD_ADDR; + case (AppConstant.TEST_CODE): + return ELK_TEST_ADDR; + default: + return ELK_DEV_ADDR; + } + } + } diff --git a/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java b/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java index 16d75912..0e10e6d0 100644 --- a/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java +++ b/blade-common/src/main/java/org/springblade/common/launch/LauncherServiceImpl.java @@ -39,6 +39,8 @@ public class LauncherServiceImpl implements LauncherService { PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", CommonConstant.nacosAddr(profile)); PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", CommonConstant.sentinelAddr(profile)); PropsUtil.setProperty(props, "spring.zipkin.base-url", CommonConstant.zipkinAddr(profile)); + // 开启elk日志 + //PropsUtil.setProperty(props, "blade.log.elk.destination", CommonConstant.elkAddr(profile)); } }