Hello Ron,

Thanks a lot, the way of additionally printing stacktrace helps too and
satisfies my needs.

Best regards,
Andrej J.
 _____

From: "Ron Bodkin" <[EMAIL PROTECTED]>
Subject: RE: [aspectj-users] Proper usage of log4j
To: <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andrej Amster
Sent: Thursday, May 10, 2007 11:04 AM
To: [email protected]
Subject: [aspectj-users] Proper usage of log4j



Hello,

I have declaration in my class using org.apache.log4j.Logger:
  private static final Logger log =
Logger.getLogger(PrihlaskaReportBean.class);

And i would like to ask for hint about how to formulate declare error
pointcut, which could capture following:

log.error("some message" + e);

I want to capture this logging usage, because the "+ e" calls e.toString(),
which causes to print only the message without stacktrace(stacktrace i want
to see always).

Proper usage would be(which i want to enforce):

log.error("some message", e);

Best regards,

Andrej J.
AspectJ/AJDT enthusiast
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to