org.kuali.student.common.util
Class SimpleExceptionLoggingAdvice

java.lang.Object
  extended by org.kuali.student.common.util.SimpleExceptionLoggingAdvice
All Implemented Interfaces:
org.aopalliance.aop.Advice, AfterAdvice, ThrowsAdvice

public class SimpleExceptionLoggingAdvice
extends Object
implements ThrowsAdvice

Advice to log exceptions. Default loggingLevel=STACKTRACE and exceptionLoggingType=THROWABLE.

Spring configuration example

 <aop:config>
     <aop:aspect id="exceptionLoggingAspect" ref="exceptionLoggingAdvice" order="2">
         <aop:after-throwing
             pointcut="execution(* org.kuali.student.lum.lu.service.*.*(..))"
             method="afterThrowing" throwing="t" />
     </aop:aspect>
 </aop:config>
 <bean id="exceptionLoggingAdvice" class="org.kuali.student.common.util.SimpleExceptionLoggingAdvice">
     <property name="loggingLevel" value="INFO" />
     <property name="exceptionLoggingType" value="RUNTIME" />
 </bean>
 


Nested Class Summary
private static class SimpleExceptionLoggingAdvice.ExceptionLevel
           
private static class SimpleExceptionLoggingAdvice.LoggingLevel
           
 
Field Summary
private  SimpleExceptionLoggingAdvice.ExceptionLevel exceptionType
           
private  SimpleExceptionLoggingAdvice.LoggingLevel loggingLevel
           
 
Constructor Summary
SimpleExceptionLoggingAdvice()
          Constructor.
 
Method Summary
 void afterThrowing(org.aspectj.lang.JoinPoint jp, Throwable t)
          Catches the exception being thrown.
private  void logException(Class<?> targetClass, Throwable t)
          Logs the exception.
 void setExceptionLoggingType(String exceptionType)
          Sets the type of exception to log.
 void setLoggingLevel(String loggingLevel)
          Sets the logging level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exceptionType

private SimpleExceptionLoggingAdvice.ExceptionLevel exceptionType

loggingLevel

private SimpleExceptionLoggingAdvice.LoggingLevel loggingLevel
Constructor Detail

SimpleExceptionLoggingAdvice

public SimpleExceptionLoggingAdvice()
Constructor.

Method Detail

setLoggingLevel

public void setLoggingLevel(String loggingLevel)
Sets the logging level.

Logging levels:

Parameters:
loggingLevel - Logging level

setExceptionLoggingType

public void setExceptionLoggingType(String exceptionType)
Sets the type of exception to log. E.g. Only log runtime exception (RUNTIME).

Exception types:

Parameters:
exceptionType - exception logging type

afterThrowing

public void afterThrowing(org.aspectj.lang.JoinPoint jp,
                          Throwable t)
                   throws Throwable
Catches the exception being thrown.

Parameters:
jp - Aspect join point
t - Exception being thrown
Throws:
Throwable

logException

private void logException(Class<?> targetClass,
                          Throwable t)
Logs the exception.

Parameters:
targetClass - The join point class the exception was caught.
t - Exception being thrown.


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.