.NetCore中使用AspectCore、ExceptionLess 实现AOP操作日志记录
2018-10-24 16:27
1081 查看
结合前面封装的ExceptionLess,接下来使用 AspectCore 实现AOP日志处理
nuget导入AspectCore.Core 、AspectCore.Extensions.DependencyInjection
重写抽象类AbstractInterceptorAttribute
public class OperatorLogAttribute : AbstractInterceptorAttribute { public async override Task Invoke(AspectContext context, AspectDelegate next) { //加载Exceptionless服务 var elg = context.ServiceProvider.GetService(typeof(IELLog)) as IELLog; //具体记录情况略 } }
接下来只需要在Startup中添加动态代理即可,在ConfigServices 最后加上带返回值为IServiceProvider
return services.ConfigureDynamicProxy().BuildDynamicProxyServiceProvider();
ConfigureDynamicProxy中可添加动态代理配置具体参考资料如下:
参考资料:https://www.geek-share.com/detail/2707679720.html
在我们需要记录操作日志的地方加上标签OperatorLog即可,当我们操作了某一个功能后,我们在ExecptionLess就可以看到相关操作日志
相关文章推荐
- .NetCore中使用ExceptionLess记录Polly中的操作异常日志
- [EntLib]微软企业库5.0 学习之路——第九步、使用PolicyInjection模块进行AOP—PART4——建立自定义Call Handler实现用户操作日志记录
- 使用Aop面向切面技术实现记录详细操作日志功能
- 微软企业库5.0 学习之路——第九步、使用PolicyInjection模块进行AOP—PART4——建立自定义Call Handler实现用户操作日志记录
- spring aop 实现操作日志记录
- springMVC +Mybatis +spring aop 实现用户系统操作日志记录
- .net core系列之《对AOP思想的理解及使用AspectCore实现自定义日志拦截》
- 使用spring aop + 注解完成对业务操作的日志记录
- 自定义注解和aop结合使用---自定义日志记录的实现
- 使用Spring AOP记录Controller层操作日志
- 使用自定义注解+Spring AOP 实现日志记录
- java使用动态代理来实现AOP(日志记录)的实例代码
- spring2.x使用aop实现声明式日志记录
- java使用动态代理来实现AOP(日志记录)的实例代码
- 使用Spring AOP使用注解记录用户操作日志
- Spring AOP 实现系统操作日志记录
- 基于Spring AOP和Groovy日志模板配置的日志记录框架的二次实现与使用案例
- 《web工程aop实现前台操作日志记录》初稿
- 自定义注解+Spring AOP实现记录用户操作日志
- 使用SpringAop与自定义注解实现日志记录