일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- resource
- Quartz
- context
- lsof
- xargs
- GIT
- VirtualBox
- find
- maVen
- bash
- plugin
- 줄바꿈 문자
- tomcat
- grep
- Eclipse
- vscode
- profile
- IntelliJ
- web.xml
- 네트워크
- 단축키
- import
- netsh
- Windows 10
- Mac
- JavaScript
- ssh
- Windows
- Source
- port
- Today
- Total
develog
LogAspect 본문
import java.util.List; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; public class LogAspect { public void before(JoinPoint joinPoint) { StringBuffer sb = new StringBuffer(); sb.append(getFullName(joinPoint)); sb.append(" (before)"); sb.append(getArgs(joinPoint));
MyLogger.debug(sb.toString()); }
public void afterReturning(JoinPoint joinPoint, Object ret) { StringBuffer sb = new StringBuffer(); sb.append(getFullName(joinPoint)); sb.append(" (afterReturning)");
if (ret instanceof List) { List list = (List) ret; if (list == null) { sb.append("\n" + " " + "LIST, " + "null"); } else { sb.append("\n" + " " + "LIST, " + list.size() + " 건"); } } else { sb.append("\n" + " " + ret); }
MyLogger.debug(sb.toString()); }
public void afterThrowing(JoinPoint joinPoint, Exception ex) { StringBuffer sb = new StringBuffer(); sb.append(getFullName(joinPoint)); sb.append(" (afterThrowing)"); sb.append(String.valueOf(ex));
MyLogger.debug(sb.toString()); }
public void exceptionThrowing(JoinPoint joinPoint, Exception ex) { StringBuffer sb = new StringBuffer(); sb.append(getFullName(joinPoint)); sb.append(" (exceptionThrowing)"); sb.append(String.valueOf(ex));
MyLogger.debug(sb.toString()); }
private String getFullName(JoinPoint joinPoint) { Signature signature = joinPoint.getSignature(); StringBuffer sb = new StringBuffer(); sb.append(signature.getDeclaringTypeName()); sb.append("."); sb.append(signature.getName()); return sb.toString(); }
private String getArgs(JoinPoint joinPoint) { StringBuffer sb = new StringBuffer();
Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { sb.append("\n" + " " + i + ". " + args[i]); }
return sb.toString(); }
} |
'Dev > Spring' 카테고리의 다른 글
[Spring] beans xml schema (0) | 2014.10.15 |
---|---|
Spring 에서 HttpServletRequest 접근 (0) | 2013.12.11 |
Spring AOP Pointcut expression (0) | 2013.12.11 |
Spring AOP 설정 (0) | 2013.12.11 |
Spring AOP LoggingAdvice (0) | 2013.11.29 |