0

We are working on a web application where we are logging input and output of all the database calls in DAO classes. An example is:

@Override
public List<Long> findUsers(final List<Long> userIds) {
    LOGGER.info("findUsers: finding user ids  by  followeeId {} ", userIds);
    ... // hibernate DB call
    LOGGER.info("findUsers: number of ids  founds are {}", userIdList.size());  

This code will be present inside all the DAO classes, and the number of such classes is around 100, and it may go higher.

My question is shall we continue logging the info in the same way or shall we go for Spring-AspectJ implementation? -We'll have an aspect defined for @Before and @After for all such methods. This aspect will call logger and log the required info.

Will implementing Spring-AspectJ be a performance hit? Any pointers are appreciated.

I have gone through the below SO questions, but need some more clarity with respect to the example quoted above.

Community
  • 1
  • 1
Pramod Karandikar
  • 5,289
  • 7
  • 43
  • 68

2 Answers2

4

Using AOP will give you a small performance penalty, how much depends on how you apply AOP (proxies or weaving) and what you do in your aspect. I would suggest using Springs CustomizableTraceInterceptor or if you are also interested (or more interested in performance one of the subclasses of AbstractMonitoringInterceptor saves you implementing your own.

I wouldn't log in the way you are doing it as it is easy to forget and if you want to change something (or disable logging) you have to change those 100 classes instead of 1 or just configuration.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
0

if you are using sping aop it will decrease your performance, besides if you use spring with aspectj it will perform better for more check here http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/aop.html

dursun
  • 1,861
  • 2
  • 21
  • 38