-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#157 monitoring
- Loading branch information
Showing
14 changed files
with
177 additions
and
55 deletions.
There are no files selected for viewing
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
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
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
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
24 changes: 0 additions & 24 deletions
24
Server/src/main/java/JGS/CasperEvent/global/config/SwaggerConfig.java
This file was deleted.
Oops, something went wrong.
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
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
46 changes: 46 additions & 0 deletions
46
Server/src/main/java/JGS/CasperEvent/global/interceptor/RequestInterceptor.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package JGS.CasperEvent.global.interceptor; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.NonNull; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.slf4j.MDC; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
import java.util.UUID; | ||
|
||
@Component | ||
@Slf4j | ||
public class RequestInterceptor implements HandlerInterceptor { | ||
|
||
private static final String REQUEST_ID = "requestId"; | ||
|
||
@Override | ||
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) { | ||
// UUID를 사용해 고유한 requestId 생성 | ||
String requestId = UUID.randomUUID().toString(); | ||
|
||
// MDC에 requestId 추가하여 로깅 시 포함되도록 설정 | ||
MDC.put(REQUEST_ID, requestId); | ||
|
||
String requestURI = request.getMethod() + " " + request.getRequestURL(); | ||
|
||
String queryString = request.getQueryString(); | ||
|
||
log.info("Request [{}{}]", requestURI, queryString); | ||
|
||
// 요청의 헤더에 requestId 추가 (선택 사항) | ||
response.addHeader(REQUEST_ID, requestId); | ||
|
||
return true; // 다음 인터셉터나 컨트롤러로 요청 전달 | ||
} | ||
|
||
@Override | ||
public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, Exception ex) { | ||
log.info("Response {} [{}]", response.getStatus(), handler); | ||
|
||
// 요청이 완료된 후 MDC에서 requestId 제거 | ||
MDC.remove(REQUEST_ID); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
spring: | ||
application: | ||
name: hybrid-jgs | ||
jpa: | ||
show-sql: true | ||
show-sql: false | ||
# 데이터베이스 설정은 공통으로 지정하지 않음 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<configuration> | ||
<!-- 콘솔 출력 설정 --> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- INFO 로그 파일 설정 --> | ||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>logs/info.log</file> <!-- 프로젝트 디렉토리 내 logs 폴더 --> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>logs/info.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern> | ||
</encoder> | ||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
<level>INFO</level> | ||
<onMatch>ACCEPT</onMatch> | ||
<onMismatch>DENY</onMismatch> | ||
</filter> | ||
</appender> | ||
|
||
<!-- ERROR 로그 파일 설정 --> | ||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>logs/error.log</file> <!-- 프로젝트 디렉토리 내 logs 폴더 --> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>logs/error.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern> | ||
</encoder> | ||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
<level>ERROR</level> | ||
<onMatch>ACCEPT</onMatch> | ||
<onMismatch>DENY</onMismatch> | ||
</filter> | ||
</appender> | ||
|
||
<!-- WARN 로그 파일 설정 --> | ||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>logs/warn.log</file> <!-- 프로젝트 디렉토리 내 logs 폴더 --> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>logs/warn.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
</rollingPolicy> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg [%X{requestId}]%n</pattern> | ||
</encoder> | ||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | ||
<level>WARN</level> | ||
<onMatch>ACCEPT</onMatch> | ||
<onMismatch>DENY</onMismatch> | ||
</filter> | ||
</appender> | ||
|
||
<!-- 루트 로거 설정: 콘솔과 파일에 모두 출력 --> | ||
<root level="INFO"> | ||
<appender-ref ref="STDOUT" /> | ||
<appender-ref ref="INFO_FILE" /> | ||
<appender-ref ref="ERROR_FILE" /> | ||
<appender-ref ref="WARN_FILE" /> | ||
</root> | ||
</configuration> |
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
Oops, something went wrong.