public class MethodExecutionTimeLogger extends Object
The MethodExecutionTimeLogger class contains utility method which can be used to log the method execution time.
To use, inherit this class in your actual AspectJ class where you define advice method and point-cut methods.
The advice method of your AspectJ class should use/call method proceedAndLogExecutionTime(org.aspectj.lang.ProceedingJoinPoint) for logging
the method execution time in log files.
To use this class, perform following steps
proceedAndLogExecutionTime(org.aspectj.lang.ProceedingJoinPoint). This will log the method execution time| Constructor and Description |
|---|
MethodExecutionTimeLogger() |
| Modifier and Type | Method and Description |
|---|---|
protected org.slf4j.Logger |
getLogger()
Get the logger
|
protected Object |
proceedAndLogExecutionTime(org.aspectj.lang.ProceedingJoinPoint point)
This method will log the method duration time if the execution time exceeds specified minimum duration time.
|
protected void |
setLogger(org.slf4j.Logger log)
Specify your own logger where you want the method duration time to be logged
|
void |
setMinimumDuration(int time)
Specify the minimum duration time of methods in milliseconds.
|
protected final void setLogger(org.slf4j.Logger log)
log - protected final org.slf4j.Logger getLogger()
public final void setMinimumDuration(int time)
time - minimum duration time of methods in milliseconds (exclusive)protected final Object proceedAndLogExecutionTime(org.aspectj.lang.ProceedingJoinPoint point) throws Throwable
point - ProceedingJoinPoint reference from your advice methodThrowableCopyright © 2017. All rights reserved.