1) Can you use AOP for logging ? Well yes you can use AOP for implementing cross cutting concerns like Logging, security but under the covers you will still be using your log4j for actually adding lines to your log files.
Also, IMHO you will be better off using both log4j directly and spring AOP for logging. Just choose what you need to implement where.
2) Is Spring AOP better or AspectJ : This is a passage from Spring online documentation Documentation section 6.1.2 Hope it solves your problem.
Spring AOP capabilities and goals
Spring AOP's approach to AOP differs from that of most other AOP frameworks. The aim is not to provide the most complete AOP implementation (although Spring AOP is quite capable); it is rather to provide a close integration between AOP implementation and Spring IoC to help solve common problems in enterprise applications.
Thus, for example, the Spring Framework's AOP functionality is normally used in conjunction with the Spring IoC container. Aspects are configured using normal bean definition syntax (although this allows powerful "autoproxying" capabilities): this is a crucial difference from other AOP implementations. There are some things you cannot do easily or efficiently with Spring AOP, such as advise very fine-grained objects (such as domain objects typically): AspectJ is the best choice in such cases. However, our experience is that Spring AOP provides an excellent solution to most problems in J2EE applications that are amenable to AOP.
Spring AOP will never strive to compete with AspectJ to provide a comprehensive AOP solution. We believe that both proxy-based frameworks like Spring AOP and full-blown frameworks such as AspectJ are valuable, and that they are complementary, rather than in competition. Spring 2.0 seamlessly integrates Spring AOP and IoC with AspectJ, to enable all uses of AOP to be catered for within a consistent Spring-based application architecture. This integration does not affect the Spring AOP API or the AOP Alliance API: Spring AOP remains backward-compatible.
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss