调整日志打印参数优先级

This commit is contained in:
2026-04-25 11:33:05 +08:00
parent 36ec316998
commit 07be576c06
2 changed files with 22 additions and 3 deletions

View File

@@ -321,9 +321,15 @@ public class LogBus implements BaseParams {
logBody.setStackTrace(fmtStackTrace(stackTrace, geWarn ? null : config.getIncludeStackTrace())); logBody.setStackTrace(fmtStackTrace(stackTrace, geWarn ? null : config.getIncludeStackTrace()));
// 是否打印日志 // 是否打印日志
if (geWarn || (Objects.nonNull(print) ? print : config.getPrint().booleanValue())) { if (Objects.nonNull(print)) {
if (print) {
printLog(logBody); printLog(logBody);
} }
} else {
if (geWarn || config.getPrint()) {
printLog(logBody);
}
}
// 异常日志不做忽略 // 异常日志不做忽略
if (!geWarn) { if (!geWarn) {
// 不保存日志 // 不保存日志

View File

@@ -2,6 +2,7 @@ package xtools.boot.web.base.exception;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.connector.ClientAbortException;
import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
@@ -147,6 +148,19 @@ public class GlobalControllerExceptionHandler implements BaseParams {
return new Result<>(ResultType.NOT_FOUND, null); return new Result<>(ResultType.NOT_FOUND, null);
} }
/**
* 客户端提前断开连接
*
* @param e 客户端提前断开连接异常
* @param request 请求
*/
@ExceptionHandler(ClientAbortException.class)
public void handleClientAbortException(ClientAbortException e, HttpServletRequest request) {
String title = "客户端提前断开连接";
LogBus.init(LogLevel.WARN, LogBusBaseType.HTTP_RESPONSE).print(false).error(e).title(title).save();
logException(title, e.getMessage(), request, e);
}
/** /**
* 认证异常 * 认证异常
* *
@@ -160,7 +174,6 @@ public class GlobalControllerExceptionHandler implements BaseParams {
return new Result<>(ResultType.UNAUTHORIZED, null); return new Result<>(ResultType.UNAUTHORIZED, null);
} }
/** /**
* 公钥错误 * 公钥错误
* *