log request uri
This commit is contained in:
parent
4351c0ef03
commit
a3cf035609
@ -28,9 +28,9 @@ public class MdcRequestIdFilter extends OncePerRequestFilter {
|
|||||||
|
|
||||||
// 静态资源后缀列表
|
// 静态资源后缀列表
|
||||||
private static final String[] STATIC_RESOURCES = {
|
private static final String[] STATIC_RESOURCES = {
|
||||||
".css", ".js", ".jpg", ".jpeg", ".png", ".gif", ".ico", ".svg", ".woff", ".woff2", ".ttf", ".eot", ".map", ".gz", ".rar", ".zip", ".7z", ".pdf",
|
"css", "js", "jpg", "jpeg", "png", "gif", "ico", "svg", "woff", "ttf", "eot", "map", "gz", "rar", "zip", "7z", "pdf",
|
||||||
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt", ".mp3", ".mp4", ".avi", ".wmv", ".flv", ".swf", ".exe", ".dll", ".ico", ".psd", ".ai",
|
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "mp3", "mp4", "avi", "wmv", "flv", "swf", "exe", "dll", "ico", "psd", "ai",
|
||||||
".eps", ".svg", ".ttf", ".woff", ".woff2", ".eot", ".otf", ".otc", ".ttc", ".ttf", ".woff", ".woff2", ".eot", ".otf", "json"
|
"eps", "svg", "ttf", "woff", "woff2", "eot", "otf", "otc", "ttc", "ttf", "woff", "woff2", "eot", "otf", "json"
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,7 +50,7 @@ public class MdcRequestIdFilter extends OncePerRequestFilter {
|
|||||||
String traceId = request.getHeader(REQUEST_ID_KEY);
|
String traceId = request.getHeader(REQUEST_ID_KEY);
|
||||||
if (traceId == null) {
|
if (traceId == null) {
|
||||||
traceId = UUID.randomUUID().toString().replace("-", "");
|
traceId = UUID.randomUUID().toString().replace("-", "");
|
||||||
log.info("requestId为空,自动生成 {}, client ip: {}", traceId, clientIp);
|
log.info("request uri:{} requestId为空,自动生成 {}, client ip: {}", uri, traceId, clientIp);
|
||||||
request.setAttribute(REQUEST_ID_KEY, traceId);
|
request.setAttribute(REQUEST_ID_KEY, traceId);
|
||||||
}
|
}
|
||||||
MDC.put(REQUEST_ID_KEY, traceId);
|
MDC.put(REQUEST_ID_KEY, traceId);
|
||||||
@ -72,7 +72,7 @@ public class MdcRequestIdFilter extends OncePerRequestFilter {
|
|||||||
|
|
||||||
String lowerUri = uri.toLowerCase();
|
String lowerUri = uri.toLowerCase();
|
||||||
for (String suffix : STATIC_RESOURCES) {
|
for (String suffix : STATIC_RESOURCES) {
|
||||||
if (lowerUri.endsWith(suffix)) {
|
if (lowerUri.endsWith(suffix) || lowerUri.contains("." + suffix)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user