Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Is there any REAL logging (tracing) example of AOP

As I just replied to Ilker's question on TSS
( http://www.theserverside.com/home/thread.jsp?thread_id=22802#103859
),
one apporach is to "refactor" the strategy for logging into
two components: focused tracing and exceptional cases.
You then use AOP for the first and leave the rest to a 
conventional appaorach.

-Ramnivas

--- Wes Isberg <wes@xxxxxxxxxxxxxx> wrote:
> I agree with what you're saying, but don't think it limits
> the utility of AspectJ for logging or tracing or cuts
> against the design principle of AOP.
> 
> There are different notions of and uses for crosscutting,
> but if your hypothesis is that each logging or tracing
> statement is different in ways that make sense only in
> the context of the code, then it's not clear that putting
> it all in a separate module is the right thing.  This
> comes up most often with error handling, in cases where
> there isn't a policy, but each method decides what
> exceptions to throw and how to handle them.  (Maybe one
> read method should keep retrying, and another should
> fail quickly.)  Maybe there are good reasons for each
> component to be idiosyncratic, or maybe it's just a 
> bad side-effect (e.g., of incremental development)
> that means the code should be refactored.  In any
> case, while you could use aspects to refactor even
> some idiosyncratic code, doing so loses the code
> context, which in some cases makes it less readable
> and maintainable.
> 
> But some debugging and most tracing doesn't follow this
> pattern.  It generally happens around join points, and
> there is usually some function for generating the
> trace message from the join point context.  Indeed,
> one of the best techniques is to maintain the message
> separately.  E.g., I keep a stack for the semantic context
> ("starting test", "creating mock exception", "controller 
> signalled wait"), and print the whole thing when tracing
> so I have a user-level trace of what's happening.  
> 
> btw, I like this question because even when it's clear
> that "logging code" is scattered and that you can define
> aspects to advise join points at substantially the same
> times in the code, there might still be data/context
> in the code or the message that might mean the logging
> makes more sense (readable, maintainable) if left 
> in context.  AOP is not a mechanical process of extracting
> code snippets to put in one place if they are scattered.
> Gregor has said his goal is to get the code to look more
> like the design, and things can be idiosyncratic by design.
> 
> My .02...
> Wes
> 
> 
> On Wed, 10 Dec 2003 09:02:27 -0500
>  ilker kiris <ilker@xxxxxxxxxx> wrote:
> > Hello folks,
> > 
> > I must admit that I'm a new bee on AOP. 
> > From the examples and papers that I can see, logging is
> > commonly used as
> > an example. 
> > But in real life, logging tools are mainly used as
> > tracing tools. 
> > Meaning, in various parts of code, different strings need
> > to be printed
> > to logs. 
> > In that case all these logging examples DON'T really
> > apply. 
> > Because the examples that I see, assume the logging is
> > used to print the
> > name of Class:method:parametersPassedIn for each method. 
> > But this is NOT how logging is used (as a trace). 
> > Hence I don't see how AOP can be used for logging. 
> > Any AOP logging example that addresses what I'm saying
> > here? 
> > 
> > Regards, 
> > -- ilker  (I hope my question isn't too arrogant :)
> > _______________________________________________
> > 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


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/


Back to the top