Skip to content

Instantly share code, notes, and snippets.

@JunNakamura
Created February 29, 2016 03:15
Show Gist options
  • Save JunNakamura/414e1b18f35bc459c800 to your computer and use it in GitHub Desktop.
Save JunNakamura/414e1b18f35bc459c800 to your computer and use it in GitHub Desktop.
javaでメソッド毎のロギング ref: http://qiita.com/n_slender/items/2f0c8b1d0226734d664c
@Around("execution(public * hoge.*.*(..))")
public Object logging(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
String method = proceedingJoinPoint.getSignature().toShortString();
try {
logger.info("START {}", method);
return proceedingJoinPoint.proceed();
} catch (Throwable t) {
logger.warn("{} failed.", method);
throw t;
} finally {
stopWatch.stop();
logger.info("END {}", method);
}
}
}
@Loggable
public int doSomething(int a) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment