From 81d8a6c82b861f4261e51195d1b098a8b4664aee Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 3 Jul 2020 13:22:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=89=E9=92=89=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=94=B9=E9=80=A0-=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/filter/LogMsgSendFilter.java | 9 +++++ .../src/main/resources/logback-spring.xml | 1 + .../com/epmet/controller/DemoController.java | 33 +++++++++++++++++++ .../src/main/resources/logback-spring.xml | 1 + 4 files changed, 44 insertions(+) create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index 2ffe50a5f4..f97e405ed0 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -28,6 +28,7 @@ public class LogMsgSendFilter extends LevelFilter { private String webHook; private String secret; private String activeEnv; + private String appName; @Override public FilterReply decide(ILoggingEvent event) { @@ -41,6 +42,10 @@ public class LogMsgSendFilter extends LevelFilter { stringBuilder.append("告警级别:" + event.getLevel()); stringBuilder.append("\n"); + if (StringUtils.isNotBlank(appName)) { + stringBuilder.append("服务名称:" + appName); + stringBuilder.append("\n"); + } if (StringUtils.isNotBlank(activeEnv)) { stringBuilder.append("告警环境:" + EnvEnum.getEnum(activeEnv).getName()); stringBuilder.append("\n"); @@ -122,6 +127,10 @@ public class LogMsgSendFilter extends LevelFilter { this.activeEnv = activeEnv; } + public void setAppName(String appName) { + this.appName = appName; + } + public void setWebHook(String webHook) { this.webHook = webHook; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml index 3d93d8a331..9a76a9c74f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml @@ -136,6 +136,7 @@ ${activeEnv} ${webHook} ${secret} + ${appname} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java new file mode 100644 index 0000000000..ccb3d23d6a --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.controller; + +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 定时任务 + * + * @author Mark sunlightcs@gmail.com + */ +@Slf4j +@RestController +@RequestMapping("demo") +@Api(tags="定时任务") +public class DemoController { + @GetMapping("testAlarm") + public void testAlarm() { + //for (int i = 0; i < 20; i++) { + log.error("测试消息"); + //} + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml b/epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml index 9f63b9901f..fcfb1de19e 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml +++ b/epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml @@ -135,6 +135,7 @@ ${activeEnv} ${webHook} ${secret} + ${appname}