[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Logging Exceptions
|
What is the best way to log Exceptions?
In code below, I show a simple program to test Logging Exceptions..
But in this example, will appear somethig like this in log>(Is this the
best way???? I think not.. but what is better?)
13/03/2006 15:48:17 Test coisa
SEVERE: java.lang.RuntimeException: bar
13/03/2006 15:48:17 Test foo
SEVERE: java.lang.RuntimeException: bar
13/03/2006 15:48:17 Test main
SEVERE: java.lang.RuntimeException: bar
Exception in thread "main" java.lang.Exception: bar
at Test.foo(Test.java:15)
at Test.main(Test.java:10)
Example:
I have this class:
public class Test {
public static void main(String s[]) throws Exception{
foo(new Test());
}
private static void foo(Test t) throws Exception{
throw new Exception("bar");
}
}
And I have this aspect:
import java.util.logging.*;
import org.aspectj.lang.*;
public privileged aspect TestAspect {
public static final Logger LOGGER =
Logger.getLogger(TestAspect.class.getName());
after() throwing (Exception ex): within(Test){
Signature sig = thisJoinPointStaticPart.getSignature();
LOGGER.logp(Level.SEVERE,
sig.getDeclaringType().getSimpleName(), sig.getName(), ex.toString());
}
}
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora!
http://br.acesso.yahoo.com