一、日志处理
1、记录日志内容
- 请求 url
- 访问者 ip
- 调用方法 classMethod
- 参数 args
- 返回内容
2、创建记录日志类
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610162126110.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
在package net.zjs.lrm.aspect;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class LogAspect {
private final Logger logger= LoggerFactory.getLogger(this.getClass());
@Pointcut("execution(* net.zjs.lrm.web.*.*(..))")
public void log(){
}
@Before("log()")
public void doBefore(){
logger.info("-----------doBefor---------");
}
@After("log()")
public void doAfter(){
logger.info("---------doAfter----------");
}
@AfterReturning(returning = "result",pointcut = "log()")
public void doAfterRututn(Object result){
logger.info("Result:{}"+result);
}
}
3、修改控制器代码
![在这里插入图片描述](https://img-blog.csdnimg.cn/202106101622106.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
4、查看控制台
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610163010269.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
5、清除执行顺序
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610163150776.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
6、修改代码
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610164242389.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610164301207.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
7、运行服务器,查看结果
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610164215801.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
8、查看日志文件
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210610164457918.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ4ODM4OTgw,size_16,color_FFFFFF,t_70)
二、页面处理
<