Thursday, February 11, 2010

spring 2.5.6 performance monitoring

1. update the applicationContext.xml as below:

 <!--  Performance monitoring. Log level should be set to TRACE to monitor the performance.  -->
    <aop:config>
           <aop:advisor pointcut="execution(* com.pkg..*.*(..))" advice-ref="performanceMonitor"/>
    </aop:config>
    <bean id="performanceMonitor" class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor"/>

2. Modify log4j.properties as below:
log4j.logger.org.springframework.aop.interceptor.PerformanceMonitorInterceptor=TRACE

3. The following pom configuration is necessary
<!-- monitor performance dependencies -->
        <dependency>
          <groupId>aspectj</groupId>
          <artifactId>aspectjweaver</artifactId>
          <version>1.5.4</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2</version>
        </dependency>

<!-- Spring dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>2.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>2.5.6</version>
        </dependency>

4. You will see the logs as below
TRACE - StopWatch 'com.xyz.dao.procedure.StoredProcedureFactory.getStoredProcedure': running time (millis) = 31
......


No comments: