add:添加定时器日志

fix:修复日志打印时没有traceId问题
opt:优化日志输出所有Get日志都不输出
This commit is contained in:
zhangzq
2026-07-11 12:45:23 +08:00
parent 24811fbec1
commit 5ae5e1fe3a
5 changed files with 35 additions and 51 deletions

View File

@@ -10,7 +10,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;import org.nl.common.base.ResponseData;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

View File

@@ -38,7 +38,6 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(Throwable.class)
public ResponseEntity handleException(Throwable e) {
log.error(ThrowableUtil.getStackTrace(e));
return ResponseData.error(e.getMessage());
}
@@ -58,8 +57,6 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = BadRequestException.class)
public ResponseEntity badRequestException(BadRequestException e) {
// 打印堆栈信息
log.error(ThrowableUtil.getStackTrace(e));
return ResponseData.error(e.getMessage());
}
}

View File

@@ -60,7 +60,6 @@ public class LogAspect {
*/
@Around("@annotation(logAnno)")
public Object logAround(ProceedingJoinPoint joinPoint,org.nl.common.logging.annotation.Log logAnno) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
String params = getParameter(method, joinPoint.getArgs());
@@ -70,19 +69,15 @@ public class LogAspect {
MDC.put("requestMethod",url);
MDC.put("requestIp", requestIp);
MDC.put("requestTime", DateUtil.now());
//请求方式GET,POST
MDC.put("urlMethod", request.getMethod());
LuceneAppender.traceIdTL.set(BaseCode.intToChars(IdUtil.getLongId()));
Object result = null;
long comming = System.currentTimeMillis();
try {
log.info("[--request--][请求接口:{}][请求参数:{}]",url,params);
result = joinPoint.proceed();
// //是否把日志存到日志表
// if (logInfo.isAddLogTable()) {
// Log log = new Log("INFO", System.currentTimeMillis() - comming);
// logService.save(getUsername(), StringUtils.getBrowser(request), requestIp, joinPoint, log);
// }
}catch (Exception ex){
StringBuffer errorStack = new StringBuffer();
errorStack.append("<br/>【异常堆栈:");
String errorMsg = ex.getMessage();