I went through some of the stuffs on net regarding spring AOP and wrote a Spring AOP logger. Can you guys check my code and give your valuable inputs to improve it or if it is not proper, give me an another example of how can I achieve it?My Code is as below :@Aspectpublic class SpringAOPLogger {    @Around(execution(* com.sample.dao.*.*(..)) || execution(* com.sample.service.*.*(..))            + || execution(* com.sample.controller.*.*(..)))    public Object logMethod(ProceedingJoinPoint joinPoint) throws Throwable {        String className = joinPoint.getTarget().getClass().getSimpleName();        final Logger logger = Logger.getLogger(joinPoint.getTarget().getClass());        Object retVal = null;        try {            StringBuffer startMessageStringBuffer = new StringBuffer();            startMessageStringBuffer.append(Entered in ).append(className).append(.);            startMessageStringBuffer.append(joinPoint.getSignature().getName());            startMessageStringBuffer.append(();            Object[] args = joinPoint.getArgs();            for (Object arg : args) {                startMessageStringBuffer.append(arg).append(, );            }            if (args.length > 0) {                startMessageStringBuffer.deleteCharAt(startMessageStringBuffer.length() - 1);            }            startMessageStringBuffer.append());            //Method Entry Log            logger.debug(startMessageStringBuffer.toString());            StopWatch stopWatch = new StopWatch();            stopWatch.start();            retVal = joinPoint.proceed();            stopWatch.stop();            StringBuffer endMessageStringBuffer = new StringBuffer();            endMessageStringBuffer.append(Exit from ).append(className).append(.);            endMessageStringBuffer.append(joinPoint.getSignature().getName());            endMessageStringBuffer.append((..); Execution time: );            endMessageStringBuffer.append(stopWatch.getTotalTimeMillis());            endMessageStringBuffer.append( ms;);            //Method Exit Log            logger.debug(endMessageStringBuffer.toString());        } catch (Throwable ex) {            StringBuffer errorMessageStringBuffer = new StringBuffer();            // Create error message            logger.error(errorMessageStringBuffer.toString(), ex);            throw ex;        }        return retVal;    }}and below is the spring xml configuration for the same :    <aop:aspectj-autoproxy>        <aop:include name=springAopLogger />    </aop:aspectj-autoproxy>    <bean id=springAopLogger class=com.sample.utility.SpringAOPLogger />
Spring AOP Log4j Logger example, improvement
java;logging;spring;aspect oriented