| RE: [aspectj-users] Proper usage of log4j |
|
You can’t really match this use with
the static pointcuts available to declare error. Under the covers this is just
a call to StringBuilder.append with a Throwable instance, but there’s no way
to say the static type of the argument is a Throwable. Another strategy would
be to flag an error if you log without logging the exception inside a handler,
but you can’t say lexically within handler in an AspectJ pointcut, and
you can’t use cflow for declare error/warning. However, what you might want to do instead
is to ADD the stack trace in advice: after(Logger logger, Throwable t) returning:
(call(* Category.*(..)) || call(* Logger.*(..))) && args(*) && cflow(handler(t))
&& target(logger) { logger.error(“Cause”,
t); } This could be refined to call the right
log level and to only trigger once per handler (e.g., using a percflow aspect). From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andrej Amster Hello, |