|
|
@@ -96,13 +96,20 @@ public class RequestLoggingFilter extends OncePerRequestFilter {
|
|
|
int status = response.getStatus();
|
|
|
|
|
|
boolean isSlow = duration >= properties.getLogging().getSlowThreshold();
|
|
|
- boolean isError = status >= 400;
|
|
|
-
|
|
|
- if (isSlow || isError) {
|
|
|
- log.warn("{} {} {} {}ms{}", method, fullUrl, status, duration,
|
|
|
+ boolean isSuccess = status >= 200 && status < 300;
|
|
|
+ boolean isRedirect = status >= 300 && status < 400;
|
|
|
+ boolean isClientError = status >= 400 && status < 500;
|
|
|
+ boolean isServerError = status >= 500;
|
|
|
+
|
|
|
+ if (isServerError) {
|
|
|
+ log.error("{} {} | IP: {} | {} | {}ms", method, fullUrl, clientIp, status, duration);
|
|
|
+ } else if (isClientError || isSlow) {
|
|
|
+ log.warn("{} {} | IP: {} | {} | {}ms{}", method, fullUrl, clientIp, status, duration,
|
|
|
isSlow ? " SLOW" : "");
|
|
|
+ } else if (isRedirect || !isSuccess) {
|
|
|
+ log.info("{} {} | IP: {} | {} | {}ms", method, fullUrl, clientIp, status, duration);
|
|
|
} else {
|
|
|
- log.debug("{} {} {} {}ms", method, fullUrl, status, duration);
|
|
|
+ log.debug("{} {} | IP: {} | {} | {}ms", method, fullUrl, clientIp, status, duration);
|
|
|
}
|
|
|
|
|
|
// 清理MDC,避免内存泄漏
|