Skip to content

Commit

Permalink
refactor: RequestLogger를 Bean으로 관리
Browse files Browse the repository at this point in the history
  • Loading branch information
xGreenNarae committed Oct 16, 2023
1 parent 1c6c692 commit 0040821
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package com.daggle.animory.common.config;

import com.daggle.animory.common.logger.RequestLogger;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class WebConfiguration implements WebMvcConfigurer {

private final RequestLogger requestLogger;

@Override
public void addInterceptors(final InterceptorRegistry registry) {

// Request Logger 를 모든 요청에 대해 적용
registry.addInterceptor(new RequestLogger()).order(-1);
registry.addInterceptor(requestLogger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -15,6 +16,7 @@
* HTTP Request의 Method, URI, Query Parameter를 로깅합니다.*
*/
@Slf4j
@Component
public class RequestLogger implements HandlerInterceptor {

@Override
Expand Down

0 comments on commit 0040821

Please sign in to comment.