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)); } }