Skip to content

Commit

Permalink
chore : Add logback executionTime
Browse files Browse the repository at this point in the history
  • Loading branch information
gachon sw academy authored and gachon sw academy committed Aug 26, 2023
1 parent a14f8ef commit 06b4e04
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/momentum/releaser/logging/ReqResAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,19 @@ private Map<String, String> getParams(HttpServletRequest request) {
// return result;
// }


@Around("bean(*Controller)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object proceed = joinPoint.proceed();
long endTime = System.currentTimeMillis();

long executionTime = endTime - startTime;

MDC.put("executionTime", String.valueOf(executionTime));

log.info("{} executed in {} ms", joinPoint.getSignature(), executionTime);

return proceed;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ spring:
local: local, common

# 활성 프로필 설정
active: dev
active: local

---
# dev
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
"log.level": "%-5level",
"message": "%message",
"process.thread.name": "%t",
"log.logger": "%C{2}"
"log.logger": "%C{2}",
"sessionId": "%X{sessionId}",
"clientIp": "%X{clientIp}",
"serverIp": "%X{serverIp}",
"methodName": "%X{methodName}",
"executionTime": "%X{executionTime}"
}
</pattern>
</pattern>
Expand Down

0 comments on commit 06b4e04

Please sign in to comment.