我采用aop来实现日志集中处理,因此配置了如下代码 <bean id ="exceptionLog" class="com.spring.exception.ExceptionLog"/>
<bean id="exceptionHandlereAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref bean="exceptionLog"/>
</property>
<property name="patterns">
<value>.*.* </value>
</property>
</bean>
我采用这样的方法实现异常集中管理,却发现,即使出现了异常,日志也没有记录下来,请问怎么回事哦?
我的异常类是
package com.spring.exception;
import java.lang.reflect.Method;import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.aop.ThrowsAdvice;
public class ExceptionLog implements ThrowsAdvice{
private Logger logger= Logger.getLogger(this.getClass().getName());
public void afterThrowing(Method method,Object[] args,Object target,Throwable subclass)throws Throwable{
logger.log(Level.INFO, args[0] +"执行" +method.getName()+"时有异常抛出......" + subclass);
}
}
<bean id="exceptionHandlereAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref bean="exceptionLog"/>
</property>
<property name="patterns">
<value>.*.* </value>
</property>
</bean>
我采用这样的方法实现异常集中管理,却发现,即使出现了异常,日志也没有记录下来,请问怎么回事哦?
我的异常类是
package com.spring.exception;
import java.lang.reflect.Method;import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.aop.ThrowsAdvice;
public class ExceptionLog implements ThrowsAdvice{
private Logger logger= Logger.getLogger(this.getClass().getName());
public void afterThrowing(Method method,Object[] args,Object target,Throwable subclass)throws Throwable{
logger.log(Level.INFO, args[0] +"执行" +method.getName()+"时有异常抛出......" + subclass);
}
}
package com.spring.exception;
import java.lang.reflect.Method; import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.aop.ThrowsAdvice;
public class ExceptionLog implements ThrowsAdvice{
private Logger logger= Logger.getLogger(this.getClass().getName());
public void afterThrowing(Method method,Object[] args,Object target,Throwable subclass)throws Throwable{
logger.log(Level.INFO, args[0] +"执行" +method.getName()+"时有异常抛出......" + subclass);
}
}
这段代码,我故意,让程序抛出异常,发现,程序没找到这里来,我想,应该这段配置根本没起到作用吧