Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Can AOP really solve the "logging problem"?

Title: RE: [aspectj-users] Can AOP really solve the "logging problem"?

"Temporary or local information" sounds more like debugging than logging IMHO. If it truly is logging information I would take a careful look at the system design and perform refactoring to expose the logging context. I would not recommend a 'hack'. Definitely start with a clear understanding of what you need to be logging and why, which in turn drives the decisions about what context needs to be exposed.

I have been using patterns like this for my logging:
pointcut majorLogPoint( Customer c, Request r) : call( * Customer.*Request( Request ) ) &&
                target( c ) && args( r ) && !within( Customer );
after( Customer c, Request r ) returning: majorLogPoint( c, r ) {
   logger.info( "Processed request " + r.getType() + " for customer " + c.getName() );
}
and
after( Customer c, Request r ) throwing (Exception e): majorLogPoint( c, r ) {
   logger.warning( "Unable to process request " + r.getType() + " for customer " + c.getName() " because of exception " + e );

}
I use similar patterns for fine, finer and finest logPoint pointcuts.
It isn't perfect, but it is much easier playing with the log points in self contained
aspects without having to check out all the classes in the package. I am using it only in a small demo project right now (6 packages, less than 100 classes), but I can only think that the advantages would increase as the application got larger.

As with most AspectJ work, the tricky, challenging and really fun part is defining good pointcuts. I am really looking forward to the day that Chapter 4 of the AspectJ programming guide includes hundreds of idioms.

Elizabeth

-----Original Message-----
From: Charles Zhang [mailto:czhang@xxxxxxxxxxxxxxxx]
Sent: Friday April 11, 2003 12:34 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Can AOP really solve the "logging problem"?


My experience is AspectJ as it is right now can't nicely solve the logging
problem. The reason is logging often involves intermediate states of the
program which largely involves temporary or local information. Accessing
local information is prohibited by AspectJ. The usual hack I do is to
write temporary methods to expose the logging context. That is bad because
it requires the coordination of the base program.

Just a thought.

Charles Zhang          
Graduate Student, Middleware Systems Research Group
ECE, U. of Toronto (http://www.eecg.utoronto.ca/~czhang)
" Yawn!!" 

On Fri, 11 Apr 2003, John W. Cocula wrote:

> I have seen references to the hypothesis that AOP in general, and
> AspectJ in particular, can separate out the concern of *logging* (not
> tracing) in large systems.  In fact, an excellent Xerox PARC
> presentation referenced Tomcat's extremely messy logging as a target for
> AOP.
>
> But I have yet to find a detailed treatment of how logging could be
> cleanly separated with AOP or AspectJ.  Does anyone have any concrete
> references?
>
> Many thanks for your help.
>
> Regards,
> John
>
> _______________________________________________
> 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


Back to the top