Revision history [back]

click to hide/show revision 1
initial version

answered 2019-01-04 00:41:21 +0800

hf gravatar image hf

Hi Andrea,

I tried your solution, but for me it doesn't work. In my applicationContext.xml I added this lines:

<aop:config>
    <aop:aspectj>

        <!-- definitions of aspects available to the weaver, and which ones should 
            be used or not used -->
        <aop:aspects>
            <aop:aspect name="it.hf.gerapweb.spring.LoggingAspect" />
        </aop:aspects>

        <!-- control over the weaver itself and the types that will be woven -->
        <aop:weaver options="-showWeaveInfo">
            <aop:include within="it.hf.gerapweb.bind.funzioni..*" />
        </aop:weaver>
    </aop:aspectj>
</aop:config>

The class LoggingAspect is:

package it.hf.gerapweb.spring;

import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.slf4j.Logger; import org.slf4j.LoggerFactory;

@Aspect public class LoggingAspect {

private static Logger log = LoggerFactory.getLogger(LoggingAspect.class);

public LoggingAspect() {
    log.info("Costruttore");
}


@Around("execution(* it.hf.gerapweb.bind.funzioni..*(..))")
public void invoke() {      
    log.info("Before");
    log.info("After");
}

}

I added spring-instrument-tomcat-4.3.21.RELEASE.jar in my tomcat7 lib and in context.xml:

<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"></Loader>

Thanks a lot. Nico

Hi Andrea,

I tried your solution, but for me it doesn't work. In my applicationContext.xml I added this lines:

<aop:config>
    <aop:aspectj>

        <!-- definitions of aspects available to the weaver, and which ones should 
            be used or not used -->
        <aop:aspects>
            <aop:aspect name="it.hf.gerapweb.spring.LoggingAspect" />
        </aop:aspects>

        <!-- control over the weaver itself and the types that will be woven -->
        <aop:weaver options="-showWeaveInfo">
            <aop:include within="it.hf.gerapweb.bind.funzioni..*" />
        </aop:weaver>
    </aop:aspectj>
</aop:config>

The class LoggingAspect is:

package it.hf.gerapweb.spring;

import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.slf4j.Logger; import org.slf4j.LoggerFactory;

org.slf4j.LoggerFactory; @Aspect public class LoggingAspect {

{

    private static Logger log = LoggerFactory.getLogger(LoggingAspect.class);

 public LoggingAspect() {
     log.info("Costruttore");
 }


 @Around("execution(* it.hf.gerapweb.bind.funzioni..*(..))")
 public void invoke() {      
     log.info("Before");
     log.info("After");
    }

}

}

I added spring-instrument-tomcat-4.3.21.RELEASE.jar in my tomcat7 lib and in context.xml:

<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"></Loader>

Thanks a lot. Nico

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More