瀏覽代碼

add 阿里云日志

A17404李放 3 年之前
父節點
當前提交
2cdba8d2fb

+ 20 - 0
nb-common/src/main/java/com/coffee/common/util/ExceptionUtil.java

@@ -0,0 +1,20 @@
+package com.coffee.common.util;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ExceptionUtil.java
+ * @Description TODO
+ * @createTime 2022年07月04日 13:49:00
+ */
+public class ExceptionUtil {
+    public static final int dept=10;
+    public static String getExceptionMsg(Exception e){
+        StringBuffer result=new StringBuffer(e.toString()).append("\n");
+        StackTraceElement[] stackTrace = e.getStackTrace();
+        for (int i = 0; i < stackTrace.length&&i<dept; i++) {
+            result.append(stackTrace[i].toString()).append("\n");
+        }
+        return result.toString();
+    }
+}

+ 2 - 1
nb-system/src/main/java/com/coffee/aliyun/AliyunConsumerGroupService.java

@@ -17,6 +17,7 @@ import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
 import com.coffee.bus.service.LocalBusDeviceService;
 import com.coffee.bus.service.LocalBusHospitalLogService;
 import com.coffee.bus.websocket.listener.DeviceInfoListener;
+import com.coffee.common.util.ExceptionUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -212,7 +213,7 @@ public class AliyunConsumerGroupService {
             hospitalLog.setSuccess(true);
         } catch (Exception e) {
             hospitalLog.setSuccess(false);
-            hospitalLog.setMessage(e.getMessage());
+            hospitalLog.setMessage(ExceptionUtil.getExceptionMsg(e));
             log.error("阿里云数据【{}】数据处理失败 ", JSONUtil.toJsonStr(message), e);
         }finally {
             if(CharSequenceUtil.isNotBlank(deviceName)){