diff --git a/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggerFilterConfig.kt b/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggerFilterConfig.kt new file mode 100644 index 00000000..72a083d2 --- /dev/null +++ b/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggerFilterConfig.kt @@ -0,0 +1,20 @@ +package com.xorker.draw.log + +import org.springframework.boot.web.servlet.FilterRegistrationBean +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.core.Ordered + +@Configuration +class ApiLoggerFilterConfig { + @Bean + fun apiLogFilter(filter: ApiLoggingFilter): FilterRegistrationBean { + val bean = FilterRegistrationBean() + + bean.filter = filter + bean.order = Ordered.HIGHEST_PRECEDENCE + bean.urlPatterns = listOf("/api/*") + + return bean + } +} diff --git a/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggingFilter.kt b/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggingFilter.kt index 16abe8ce..915c22bd 100644 --- a/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggingFilter.kt +++ b/app/api/src/main/kotlin/com/xorker/draw/log/ApiLoggingFilter.kt @@ -8,19 +8,14 @@ import jakarta.servlet.Filter import jakarta.servlet.FilterChain import jakarta.servlet.ServletRequest import jakarta.servlet.ServletResponse -import jakarta.servlet.annotation.WebFilter import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse import org.slf4j.MDC -import org.springframework.core.Ordered -import org.springframework.core.annotation.Order import org.springframework.stereotype.Component import org.springframework.web.util.ContentCachingRequestWrapper import org.springframework.web.util.ContentCachingResponseWrapper @Component -@WebFilter(urlPatterns = ["/api/*"]) -@Order(Ordered.HIGHEST_PRECEDENCE) class ApiLoggingFilter( private val objectMapper: ObjectMapper, ) : Filter {