package com.aide.web.tool; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; import java.util.Arrays; @Aspect @Component @Slf4j public class LoggingAspect { @Around("execution(* com.aide.web.controller..*(..))") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { // 获取请求方法信息 String methodName = joinPoint.getSignature().getName(); String className = joinPoint.getSignature().getDeclaringTypeName(); // 记录请求参数 Object[] args = joinPoint.getArgs(); log.info("进入的方法: {}.{} 方法参数: {}", className, methodName, Arrays.toString(args)); Object result; try { // 执行目标方法 result = joinPoint.proceed(); // 记录成功返回 log.info("方法: {}.{} 返回: {}", className, methodName, result); } catch (Throwable throwable) { // 记录异常信息 log.error("方法: {}.{} 异常信息: {}", className, methodName, throwable.getMessage()); throw throwable; } return result; } }标签:methodName,log,joinPoint,controller,result,org,import,日志 From: https://blog.csdn.net/gps666666/article/details/142989059