spring aop 异常记录
来源:互联网 发布:淘宝差评可以删除吗 编辑:程序博客网 时间:2024/05/16 00:40
- 注解? 修饰符? 返回值类型 类型声明?方法名(参数列表) 异常列表?
- 注解:可选,方法上持有的注解,如@Deprecated;--
- 该注解表示方法上----@within使用在类上
- 切入的类和被切入的类必须是被spring管理的(springIOC),如果是自己new 出来的,切入无效。
/** * 异常记录 * */ @Pointcut("execution(* com.ybt.service..*.*(..) ) || execution(* com.ybt.util..*.*(..)) && !@within(org.aspectj.lang.annotation.AfterThrowing)") public void exceptionHandler (){}; @Pointcut("execution(* com.ybt.util..*.*(..))") public void exceptionHandler2(){}; @AfterThrowing(pointcut = "exceptionHandler()",throwing="ex") public void exceptionHandlerAfterExp(JoinPoint joinPoint,Throwable ex){ StackTraceElement[] trace = ex.getStackTrace(); String exclass = trace[0].getClassName(); String method = trace[0].getMethodName(); String exceptionContent = ""; for (StackTraceElement s : trace) { exceptionContent += "\tat " + s + "\r\n"; } String params = joinPoint.getSignature().getName() + "( "; for(Object arg : joinPoint.getArgs()){ params += arg+", "; } if(params.indexOf(",") > 0){ params = params.substring(0,params.length() -2) + " )"; }else{ params = ""; } YbtException exp = new YbtException(); exp.setExClass(joinPoint.getTarget().getClass()+"-->"+exclass); exp.setException(ex.toString()); exp.setMethed(joinPoint.getTarget().getClass()+"."+joinPoint.getSignature().getName()+"()-->"+exclass+"."+ method+"()"); exp.setExceptionContent(exceptionContent); exp.setParams(params); exp.setExTime(new Date()); exceptionService.saveException(exp); }
切入的类和被切入的类必须是被spring管理的(springIOC),如果是自己new 出来的,切入无效。
0 0
- spring aop 异常记录
- spring用aop记录异常日志
- Spring + Aop+注解 集成使用 Log4j,实现异常日志记录
- 用Spring AOP实现异常处理和记录程序执行时间
- 利用Spring AOP实现业务和异常日志记录
- Spring Aop 异常
- spring aop 捕获异常
- Spring Aop异常处理
- Spring AOP xml异常
- Spring代理/aop异常
- spring aop 日志记录
- Spring AOP记录日志!
- Spring AOP记录日志! .
- Spring AOP 作用记录
- spring aop记录日志
- Spring学习记录-AOP
- Spring AOP 记录日志
- Spring AOP日志记录
- JQuery选择器
- Android 编译resource.arsc资源Resource ID解析
- ajax,SEO,谁言鱼和熊掌不可兼得
- Window中常用的属性
- ubuntu14 64位安装LAMP环境
- spring aop 异常记录
- hibernate 通过API访问数据库
- android Service总结
- C++项目之大数四则运算
- 利用bouncycastle 生成pfx公私钥文件
- SAP接口编程-RFC系列13 : Table Parameter作为输入参数
- FlywayException Unable to check whether schema "lemon" empty
- 计算机辅助设计与制造技术的结合
- VR 终极选购指南:入门、进阶与高端