Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
7c79c79e
Commit
7c79c79e
authored
Aug 19, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改网关日志
parent
db8a61d7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
base-manager/src/main/java/com/mortals/xhx/base/framework/aspect/WebLogAspect.java
...a/com/mortals/xhx/base/framework/aspect/WebLogAspect.java
+13
-4
No files found.
base-manager/src/main/java/com/mortals/xhx/base/framework/aspect/WebLogAspect.java
View file @
7c79c79e
...
...
@@ -35,6 +35,11 @@ import java.util.Map;
@Order
(
1
)
@Profile
({
"default"
,
"develop"
,
"test"
})
public
class
WebLogAspect
{
private
static
final
String
TRACE_ID
=
"traceId"
;
private
static
final
String
SPAN_ID
=
"spanId"
;
private
static
final
String
PSPAN_ID
=
"pspanId"
;
@Pointcut
(
"execution(public * com.mortals..*Controller.*(..))"
)
public
void
webLog
()
{
}
...
...
@@ -63,18 +68,22 @@ public class WebLogAspect {
public
void
afterReturning
(
Object
result
)
{
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
String
traceId
=
request
.
getHeader
(
TRACE_ID
);
String
pspanId
=
request
.
getHeader
(
PSPAN_ID
);
String
spanId
=
request
.
getHeader
(
SPAN_ID
);
Map
<
String
,
String
>
map
=
MDC
.
getCopyOfContextMap
();
if
(
map
!=
null
&&
result
!=
null
)
{
String
startTime
=
map
.
getOrDefault
(
"startTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
long
takeTime
=
(
System
.
currentTimeMillis
()
-
Long
.
parseLong
(
startTime
));
if
(
result
instanceof
String
)
{
log
.
info
(
" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}"
,
request
.
getRequestURI
(),
takeTime
,
map
.
getOrDefault
(
"req"
,
""
),
result
);
log
.
info
(
" \n 请求路径:{} 耗时:{}ms \n
traceId:{} pspanId:{} spanId:{} \n
请求报文:{} \n 响应报文:{}"
,
request
.
getRequestURI
(),
takeTime
,
traceId
,
pspanId
,
spanId
,
map
.
getOrDefault
(
"req"
,
""
),
result
);
}
else
{
log
.
info
(
" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}"
,
request
.
getRequestURI
(),
takeTime
,
map
.
getOrDefault
(
"req"
,
""
),
JSON
.
toJSONString
(
result
));
log
.
info
(
" \n 请求路径:{} 耗时:{}ms \n
traceId:{} pspanId:{} spanId:{} \n
请求报文:{} \n 响应报文:{}"
,
request
.
getRequestURI
(),
takeTime
,
traceId
,
pspanId
,
spanId
,
map
.
getOrDefault
(
"req"
,
""
),
JSON
.
toJSONString
(
result
));
}
}
...
...
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