當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
使用Spring AOP中MethodInterceptor记录日志
生活随笔
收集整理的這篇文章主要介紹了
使用Spring AOP中MethodInterceptor记录日志
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
????應用中可以使用AOP的特性來記錄各層(采用分層設計的情況下)的日志:
1,實現MethodInterceptor
import?org.aopalliance.intercept.MethodInterceptor; import?org.aopalliance.intercept.MethodInvocation; import?org.apache.commons.logging.Log; import?org.apache.commons.logging.LogFactory;public?class?ServiceMethodInterceptor?implements?MethodInterceptor{private?final?Log?LOG?=?LogFactory.getLog(ServiceMethodInterceptor.class);@Overridepublic?Object?invoke(MethodInvocation?invocation)?throws?Throwable?{Object?object?=?null;LOG.info("before?service....");object?=?invocation.proceed();LOG.info("after?service....");return?object;}}2,配置MethodInterceptor
<bean?id="serviceMethodInterceptor"?class="*.ServiceMethodInterceptor"/> .........轉載于:https://my.oschina.net/u/2500345/blog/608148
總結
以上是生活随笔為你收集整理的使用Spring AOP中MethodInterceptor记录日志的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: fork炸弹
- 下一篇: 学习用户连接性要素之连接性(附XMIND