@Aspect
@Configuration
public class ApiLogAop {
@Pointcut("execution(*
com.user.api.controller.*.*(..))")
public void excuteService(){
}
@Around("excuteService()")
public Object doAround(ProceedingJoinPoint
point) throws Throwable{
RequestAttributes ra=RequestContextHolder.getRequestAttributes();
ServletRequestAttributes
sra=(ServletRequestAttributes )ra;
HttpServletRequest request=sra.getRequest();
String url=request.getRequestURL().toString();
String method=request.getMethod();
String uri=request.getRequestURI();
String queryString=request.getQueryString();
System.out.println("萩箔蝕兵, 光倖歌方, url: "+url+",
method: "+method+", uri:"+uri+", params:"+queryString);
String simpleName=point.getTarget().getClass().getSimpleName();
String methodName=point.getSignature().getName();
MethodSignature methodSignature=(MethodSignature)
point.getSignature();
String[] parameterNames=methodSignature.getParameterNames();
Object[] param=point.getArgs();
StringBuffer str=new StringBuffer();
if(parameterNames!=null){
for(int i=0;i
str.append("歌方兆:").append(parameterNames[i]).append("=").append(param[i]);
}
}
System.out.println(str.toString());
Object result=point.proceed();
return result;
}
}