log request uri

This commit is contained in:
N1KO 2025-12-28 11:14:34 +08:00
parent 4351c0ef03
commit a3cf035609

View File

@ -28,9 +28,9 @@ public class MdcRequestIdFilter extends OncePerRequestFilter {
// 静态资源后缀列表
private static final String[] STATIC_RESOURCES = {
".css", ".js", ".jpg", ".jpeg", ".png", ".gif", ".ico", ".svg", ".woff", ".woff2", ".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",
".eps", ".svg", ".ttf", ".woff", ".woff2", ".eot", ".otf", ".otc", ".ttc", ".ttf", ".woff", ".woff2", ".eot", ".otf", "json"
"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",
"eps", "svg", "ttf", "woff", "woff2", "eot", "otf", "otc", "ttc", "ttf", "woff", "woff2", "eot", "otf", "json"
};
@Override
@ -50,7 +50,7 @@ public class MdcRequestIdFilter extends OncePerRequestFilter {
String traceId = request.getHeader(REQUEST_ID_KEY);
if (traceId == null) {
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);
}
MDC.put(REQUEST_ID_KEY, traceId);
@ -72,7 +72,7 @@ public class MdcRequestIdFilter extends OncePerRequestFilter {
String lowerUri = uri.toLowerCase();
for (String suffix : STATIC_RESOURCES) {
if (lowerUri.endsWith(suffix)) {
if (lowerUri.endsWith(suffix) || lowerUri.contains("." + suffix)) {
return true;
}
}