[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Logging debug and info
|
This is exactly what we do at VMS. We use our equivalent of the
FindPrinting aspect to help us manage log statements. We've developed
the convention that throw-away local debug statements use System.out
while more permanent log statements use our logger framework.
FindPrinting helps us remember to remove the System.out.printlns before
we check in.
Cheers,
Nick
On Jul 11, 2004, at 9:15 AM, Ron Bodkin wrote:
Hi Adrian,
I agree with your reticence to use an aspect to convert println's to
write to the logger. It would result in confusing code (even if it you
could narrow down a pointcut for all the places you wanted to log). I
think your best approach is to refactor to use logging instead.
To expand on Wes's suggestion, you can use an aspect to identify
wherever someone is accessing System.out, System.err, or printing
stack traces, so you can refactor them to use the logger, e.g.,
aspect FindPrinting {
pointcut printing(): get(System.out) || get(System.err) || call(*
printStackTrace());
declare warning: printing(): "don't print, use the logger";
}
Ron
Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895
------------Original Message------------
From: "Wes Isberg" <wes@xxxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Date: Fri, Jul-9-2004 11:05 PM
Subject: Re: [aspectj-users] Logging debug and info
Not all logging (or error-handling) belongs in an aspect. If there's
a logging policy you can express with an aspect, great. But often
logging statements are ad-hoc and properly so; they just happen to be
the information the last guy found useful to debug that particular
thing.
As for refactoring System.out.println(), etc. as log statements,
that, as you suggest, is a matter of deciphering the framer's
original intent, or having the courage to reinterpret. When looking,
don't forget to get implicit variants like printStackTrace()
(System.err), etc. The sample code linked of the AspectJ site doc
page has some useful pointcuts on point.
Wes
------------Original Message------------
From: Adrian Powell <aspectj-users@xxxxxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Date: Fri, Jul-9-2004 8:39 PM
Subject: [aspectj-users] Logging debug and info
Hi all,
I've finished reading "AspectJ In Action" and adding aspects to some
small applications of my own, and now I'm trying to figure out how to
use AspectJ for logging and tracing in my first "real" application.
I
can see how to define most of the join points which we want logged,
but
in ever application that my team wrote before, it seems that there
are
always some statements which are logged but don't follow any pattern
I
can detect. Most of them appear to be for debugging, sort of the
official version of println() statements inside loops. I was
thinking
of just surrounding all System.out.println() statements with around()
advice and redirecting it to our logger, but this isn't giving me
warm
fuzzies. Has anyone come up with a better solution?
To make things worse, it looks like some of these statements aren't
all
of the same priority either. So while most are DEBUG, some are INFO.
That would mean that I can't assume that any System.out.println() is
a
debugging statement. So ideally I'd like to find some way to log
arbitrary statements (possibly within loops) to the log with a
user-defined priority, and yet still retain the benefits that AspectJ
brings. Is this possible? Has anyone worked out any good solutions?
Thanks for any help,
-adrian.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
Nicholas Lesiecki
Software Craftsman, specializing in J2EE,
Agile Methods, and aspect-oriented programming
Books:
* Mastering AspectJ: http://tinyurl.com/66vf
* Java Tools for Extreme Programming: http://tinyurl.com/66vt
Articles on AspectJ:
* http://tinyurl.com/66vu and http://tinyurl.com/66vv