ImportCom.alibaba.fastjson.JSONObject;Importcom.alibaba.fastjson.serializer.SerializerFeature;Importorg.apache.commons.lang3.StringUtils;ImportOrg.aspectj.lang.ProceedingJoinPoint;ImportOrg.aspectj.lang.annotation.Around;ImportOrg.aspectj.lang.annotation.Aspect;Importorg.aspectj.lang.reflect.MethodSignature;ImportOrg.slf4j.Logger;Importorg.slf4j.LoggerFactory;Importorg.springframework.stereotype.Component;ImportJava.lang.reflect.Method, @Component @aspect Public classMvcmethodlogadvice {Private StaticLogger log = Loggerfactory.getlogger (mvcmethodlogadvice.class); @Around ("@annotation (org.springframework.web.bind.annotation.RequestMapping)") PublicObject Aroundadvice (Proceedingjoinpoint joinpoint)throwsthrowable {Object args[]=Joinpoint.getargs (); Methodsignature Signature=(methodsignature) joinpoint.getsignature (); Method Method=Signature.getmethod (); //join arguments.Log.info ("{}.{}: Request parameter: {}", Method.getdeclaringclass (). GetName (), Method.getname (), Stringutils.join (args, ";")); LongStart =System.currenttimemillis (); Object result=joinpoint.proceed (); Longtimeconsuming = System.currenttimemillis ()-start; Log.info ("End of call-return value: {} time-consuming: {}MS", jsonobject.tojsonstring (result, Serializerfeature.writemapnullvalue), timeconsuming); returnresult; }}
It would be nice to add this class to your project so that it will print such a log after it is set up
Very helpful for future positioning problems
Spring MVC mode blocks all ingress methods from the input parameter print