Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dinglog-spring-boot-started
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VCC
dinglog-spring-boot-started
Commits
feceab4d
Commit
feceab4d
authored
Dec 27, 2021
by
data-赵 玉龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新版本
parent
498eabb9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
13 deletions
+9
-13
pom.xml
pom.xml
+1
-1
DingTalkLogbackSendMsg.java
...cn/quantgroup/dinglog/logback/DingTalkLogbackSendMsg.java
+4
-3
LogErrorSendMsgUtil.java
.../java/cn/quantgroup/dinglog/util/LogErrorSendMsgUtil.java
+4
-9
No files found.
pom.xml
View file @
feceab4d
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
</parent>
</parent>
<groupId>
cn.quantgroup.dinglog
</groupId>
<groupId>
cn.quantgroup.dinglog
</groupId>
<artifactId>
dinglog-spring-boot-started
</artifactId>
<artifactId>
dinglog-spring-boot-started
</artifactId>
<version>
2021.12.17.
1
</version>
<version>
2021.12.17.
2
</version>
<name>
dinglog-spring-boot-started
</name>
<name>
dinglog-spring-boot-started
</name>
<description>
dinglog project for Spring Boot
</description>
<description>
dinglog project for Spring Boot
</description>
...
...
src/main/java/cn/quantgroup/dinglog/logback/DingTalkLogbackSendMsg.java
View file @
feceab4d
...
@@ -15,7 +15,8 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -15,7 +15,8 @@ import org.apache.commons.lang3.StringUtils;
*/
*/
public
class
DingTalkLogbackSendMsg
{
public
class
DingTalkLogbackSendMsg
{
public
static
void
sendMsg
(
ContextAwareBase
base
,
PatternLayoutEncoder
encoder
,
LoggingEvent
event
,
String
appenderName
,
DingTalkLogbackParam
dingTalkLogbackParam
)
{
public
static
void
sendMsg
(
ContextAwareBase
base
,
PatternLayoutEncoder
encoder
,
LoggingEvent
event
,
String
appenderName
,
DingTalkLogbackParam
dingTalkLogbackParam
)
{
//dingTalk sdk 内部日志异常,直接过滤掉,避免出现error日志死循环发钉钉消息处理
//dingTalk sdk 内部日志异常,直接过滤掉,避免出现error日志死循环发钉钉消息处理
if
(
event
.
getLoggerName
().
equalsIgnoreCase
(
"topsdk"
))
{
if
(
event
.
getLoggerName
().
equalsIgnoreCase
(
"topsdk"
))
{
...
@@ -49,7 +50,7 @@ public class DingTalkLogbackSendMsg {
...
@@ -49,7 +50,7 @@ public class DingTalkLogbackSendMsg {
layoutLog
=
dingTalkLogbackParam
.
getMarkMsg
().
concat
(
"---"
).
concat
(
layoutLog
);
layoutLog
=
dingTalkLogbackParam
.
getMarkMsg
().
concat
(
"---"
).
concat
(
layoutLog
);
}
}
DingTalkSendMsgUtil
.
sendTextMsg
(
layoutLog
,
accessToken
);
DingTalkSendMsgUtil
.
sendTextMsg
(
layoutLog
,
accessToken
);
LogErrorSendMsgUtil
.
sendMsg
(
layoutLog
,
collect_url
);
LogErrorSendMsgUtil
.
sendMsg
(
layoutLog
,
collect_url
,
dingTalkLogbackParam
.
getMarkMsg
()
);
return
;
return
;
}
}
...
@@ -86,7 +87,7 @@ public class DingTalkLogbackSendMsg {
...
@@ -86,7 +87,7 @@ public class DingTalkLogbackSendMsg {
message
=
dingTalkLogbackParam
.
getMarkMsg
().
concat
(
"---"
).
concat
(
message
);
message
=
dingTalkLogbackParam
.
getMarkMsg
().
concat
(
"---"
).
concat
(
message
);
}
}
DingTalkSendMsgUtil
.
sendTextMsg
(
message
,
accessToken
);
DingTalkSendMsgUtil
.
sendTextMsg
(
message
,
accessToken
);
LogErrorSendMsgUtil
.
sendMsg
(
message
,
collect_url
);
LogErrorSendMsgUtil
.
sendMsg
(
message
,
collect_url
,
dingTalkLogbackParam
.
getMarkMsg
()
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
base
.
addInfo
(
"ding talk logback send msg error:{}"
,
e
);
base
.
addInfo
(
"ding talk logback send msg error:{}"
,
e
);
}
}
...
...
src/main/java/cn/quantgroup/dinglog/util/LogErrorSendMsgUtil.java
View file @
feceab4d
...
@@ -2,6 +2,7 @@ package cn.quantgroup.dinglog.util;
...
@@ -2,6 +2,7 @@ package cn.quantgroup.dinglog.util;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.taobao.api.Constants
;
import
com.taobao.api.Constants
;
import
com.taobao.api.internal.util.HttpResponseData
;
import
com.taobao.api.internal.util.HttpResponseData
;
import
com.taobao.api.internal.util.WebV2Utils
;
import
com.taobao.api.internal.util.WebV2Utils
;
...
@@ -35,7 +36,7 @@ public class LogErrorSendMsgUtil {
...
@@ -35,7 +36,7 @@ public class LogErrorSendMsgUtil {
}
}
},
new
ThreadPoolExecutor
.
DiscardOldestPolicy
());
},
new
ThreadPoolExecutor
.
DiscardOldestPolicy
());
public
static
void
sendMsg
(
String
msg
,
String
url
,
Throwable
e
)
{
public
static
void
sendMsg
(
String
msg
,
String
url
,
Throwable
e
,
String
markMsg
)
{
if
(
msg
==
null
)
{
if
(
msg
==
null
)
{
return
;
return
;
...
@@ -44,7 +45,7 @@ public class LogErrorSendMsgUtil {
...
@@ -44,7 +45,7 @@ public class LogErrorSendMsgUtil {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
msg
=
msg
+
"\n"
+
getStackTraceElementMessage
(
e
);
msg
=
msg
+
"\n"
+
getStackTraceElementMessage
(
e
);
}
}
sendMsg
(
msg
,
url
);
sendMsg
(
msg
,
url
,
markMsg
);
}
}
public
static
String
getStackTraceElementMessage
(
Throwable
ex
)
{
public
static
String
getStackTraceElementMessage
(
Throwable
ex
)
{
...
@@ -85,7 +86,7 @@ public class LogErrorSendMsgUtil {
...
@@ -85,7 +86,7 @@ public class LogErrorSendMsgUtil {
}
}
public
static
void
sendMsg
(
String
msg
,
String
url
)
{
public
static
void
sendMsg
(
String
msg
,
String
url
,
String
project_name
)
{
if
(
url
!=
null
&&
url
.
trim
().
length
()
>
5
)
{
if
(
url
!=
null
&&
url
.
trim
().
length
()
>
5
)
{
executor
.
execute
(()
->
{
executor
.
execute
(()
->
{
//组装参数,准备发送
//组装参数,准备发送
...
@@ -94,12 +95,6 @@ public class LogErrorSendMsgUtil {
...
@@ -94,12 +95,6 @@ public class LogErrorSendMsgUtil {
Map
<
String
,
String
>
params
=
new
LinkedHashMap
<>();
Map
<
String
,
String
>
params
=
new
LinkedHashMap
<>();
params
.
put
(
"error_time"
,
error_time
);
params
.
put
(
"error_time"
,
error_time
);
String
project_name
=
System
.
getProperty
(
"@appId"
);
if
(
project_name
==
null
)
{
project_name
=
System
.
getProperty
(
"sun.java.command"
);
String
[]
strings
=
project_name
.
split
(
"\\."
);
project_name
=
strings
[
strings
.
length
-
1
];
}
params
.
put
(
"project_name"
,
project_name
);
params
.
put
(
"project_name"
,
project_name
);
params
.
put
(
"env"
,
System
.
getProperty
(
"env"
));
params
.
put
(
"env"
,
System
.
getProperty
(
"env"
));
params
.
put
(
"msg"
,
msg
);
params
.
put
(
"msg"
,
msg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment