Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] about using aspectj to log exceptions


I want to use aspectj to logger the exceptions. so I implemnt a aspect class named LoggerAspect below.
I can catch the exceptions now.
but how can I get where the new exception be created, what the class is and what the method is?
How to?

import org.aspectj.lang.Signature;
public aspect LoggerAspect {
pointcut exceptionLoggerMethods() : call (public && !within(LoggerAspect);
before() : exceptionLoggerMethods() {
System.out.println("aspect before exception"); Signature sig = thisJoinPointStaticPart.getSignature();
after() returning(Exception e): exceptionLoggerMethods(){
System.out.println("aspect after exception"); System.out.println(e); /////////////


after() throwing(Exception e) : execution(* *.*(..)) {
 System.out.println("aspect after throwing exception");
 System.out.println(e);  ///////////////



与联机的朋友进行交流,请使用 MSN Messenger:

Back to the top