Spring Boot 中使用Spring Aop实现日志记录功能

Spring Boot 中使用Spring Aop实现日志记录功能,第1张

一、创建日志注解

1、 日志类型枚举类

2、自定义日志注解

二、利用AOP实现日志切面统一处理

1、 日志实现类创建工厂

2、 切面类

三、 创建日志实现类

1、添加日志接口

2、添加日志接口实现类

四、controller

spring 配置aop去拦截你的action中的方法,执行日志记录

<aop:config>

<aop:pointcut id="logPointcutVac"

expression="execution(* 写你需要拦截的地址以及方法名,可以用通配符)" />

<aop:pointcut id="logPointcutVacCp"

expression="execution(* 写你需要拦截的地址以及方法名,可以用通配符)" />

<aop:pointcut id="logPointcutCrm"

expression="execution(* 写你需要拦截的地址以及方法名,可以用通配符)" />

<aop:aspect id="logging" ref="logAroundAdvice">

<aop:around pointcut-ref="logPointcutVac" method="invoke" />

<aop:around pointcut-ref="logPointcutVacCp" method="invoke"/>

<aop:around pointcut-ref="logPointcutCrm" method="invoke" />

</aop:aspect>

</aop:config>

具体这里有 http://hi.baidu.com/ryan_dream/blog/item/59154e50e5d049541138c2f2.html


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/7988324.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-12
下一篇2023-04-12

发表评论

登录后才能评论

评论列表(0条)

    保存