Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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
> 



Back to the top