Created
July 26, 2016 08:53
-
-
Save jangalinski/dad0c09a5bd003366431743be1bad9ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Aspect | |
public class LoggingAspect { | |
private static Logger logger = LoggerFactory.getLogger(LoggingAspect.class); | |
@Around("requiredLog()") | |
public Object logMethod(ProceedingJoinPoint proceedingJoinPoint) { | |
Object returnValue = null; | |
try { | |
logger.info("method -> " + proceedingJoinPoint.getSignature().toShortString() | |
+ ", arguments -> " + Arrays.asList(proceedingJoinPoint.getArgs())); | |
return proceedingJoinPoint.proceed(); | |
} catch (Throwable e) { | |
logger.error("error -> " + e.getMessage()); | |
} finally { | |
logger.info("ended -> " + proceedingJoinPoint.getSignature().toShortString()); | |
} | |
} | |
@Pointcut("within(my.package..*)") | |
public void forAllPackages() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment