• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Spring AOP for logging  RSS feed

 
Ranch Hand
Posts: 201
1
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of our existing legacy system with no logging mechanism of any sort built onto it ,the maintenance is becoming nightmarish
We have been exploring various options ,we have started a small POC on making use of Spring AOPs,We haven't yet thought about the big picture of its implication on the run time environment
Any thoughts on this would be greatly appreciated.

Thanks
 
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I split this post out of another topic and forgot to include the following)

Craig Walls wrote:
This should probably be a new thread, but...I'll answer anyway...

Logging is one of the stock answers for what AOP is good for. And for an application that has no logging whatsoever already, AOP-driven logging is probably a good start. That said, as aspects can only apply a generic logging style across methods as they're invoked, a more precise insertion of logging calls within the code will produce better results. But again, you have nothing now, so AOP driven logging is certainly better than that.

Be aware that Spring AOP has one main limitation: It works by proxying Spring beans and therefore the aspect will not be applied to any components not configured as beans in Spring and even then will not work if the caller did not obtain the instance from the container (either by injection or by asking the container for it). Moreover, if the types you want to apply an aspect to do not have an interface that they implement, you'll have to use CGLIB-based proxying as opposed to JDK-based proxying. Spring can do either...you just need to be aware of the tradeoffs.

If the limitations of Spring AOP make it unworkable for you, then there's nothing wrong with using AspectJ to achieve your AOP goals. AspectJ gives you a more complete AOP model, but the tradeoff is either compile-time weaving vs. registering an agent to perform loadtime weaving.


meenakshi sundar wrote:In one of our existing legacy system with no logging mechanism of any sort built onto it ,the maintenance is becoming nightmarish
We have been exploring various options ,we have started a small POC on making use of Spring AOPs,We haven't yet thought about the big picture of its implication on the run time environment
Any thoughts on this would be greatly appreciated.

Thanks

 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!