我使用spring aop来记录服务执行的时间,但它没有记录。我也没有得到任何例外。 帮助我解决这个问题,无论是log4j2配置中的问题还是切入点表达式都有问题。
以下是我的application-context.xml
<bean id="perfMonitor"
class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
</bean>
<aop:config proxy-target-class="true">
<aop:pointcut id="allServiceMethods" expression="execution(* com.lfr.services..*.*(..))"
/>
<aop:advisor pointcut-ref="allServiceMethods" advice-ref="perfMonitor"
order="1" />
</aop:config>
以下是我的log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %level - %m%n%ex%n" />
</Console>
<File name="log4jdbc_file" fileName="d:/logs/log4jdbc21.log">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %level - %m%n%ex%n" />
</File>
</appenders>
<loggers>
<logger name="log4jdbc.log4j2" level="info" additivity="false">
<MarkerFilter marker="LOG4JDBC_NON_STATEMENT" onMatch="DENY"
onMismatch="NEUTRAL" />
<appender-ref ref="log4jdbc_file" />
</logger>
<logger
name="org.springframework.aop.interceptor.PerformanceMonitorInterceptor"
level="trace">
<appender-ref ref="Console" />
</logger>
<root level="trace">
<appender-ref ref="Console" />
</root>
</loggers>
</configuration>