๊ฐœ๋ฐœ์ž๋กœ์„œ ์šด์˜์ด์Šˆ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋กœ๊ทธ๋ฉ”์‹œ์ง€๊ฐ€ ๋””๋ฒ„๊น…์„ ์œ„ํ•ด์„œ ๊ผญ ํ•„์š”ํ•˜๋‹ค๋Š”๊ฑด ๋ˆ„๊ตฌ๋‚˜ ์•Œ๊ณ ๊ณ„์‹ค๊ฒ๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ๋กœ๊น…์„ ์ž˜ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋งŽ์€ ๊ณ ๋ฏผ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

๋กœ๊ทธ๋ ˆ๋ฒจ์€ ์–ด๋–ป๊ฒŒ ํ• ์ง€ ๋กœ๊ทธ์˜ ๋‚ด์šฉ์€ ์–ด๋–ค ์ •๋ณด๋“ค๋กœ ์ฑ„์›Œ๋„ฃ์„์ง€ ๋“ฑ๋“ฑ ๋ง์ด์ฃ .

๋กœ๊ทธ๋Š” ๋งŽ์ด ๋‚จ๊ธด๋‹ค๊ณ  ์ข‹์€๊ฒŒ ์•„๋‹ˆ์ฃ .

์–ด๋–ค ๋ถ„๋“ค์€ ์•„๋ฌด๋Ÿฐ ์˜๋ฏธ๋„ ์—†๋Š” ์ •๋ณด๋ฅผ ๋กœ๊น…ํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

๋น„์šฉ์ ์ธ ์ธก๋ฉด์ด ๋ฌธ์ œ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ๋Œ€๋Ÿ‰์˜ ๋กœ๊ทธ๋ฅผ ๋งˆ์Œ๊ป ๋‚จ๊ฒจ๋„ ๋˜๊ฒ ์ง€๋งŒ ํ˜„์‹ค์€ ๊ทธ๋ ‡์ง€ ์•Š์ฃ .

๋”ฐ๋ผ์„œ ์ค‘์š”๋„์— ๋”ฐ๋ผ์„œ ์ ๋‹น~~ํžˆ ์ตœ์†Œํ•œ์˜ ๋‚ด์šฉ๋งŒ ๋กœ๊น…ํ•˜๋Š”๊ฒŒ ์ข‹์Šต๋‹ˆ๋‹ค.

๋กœ๊ทธ ์ค‘์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๋กœ๊ทธ๋Š” ์š”์ฒญ๊ณผ ์‘๋‹ต์— ๋Œ€ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

API ์š”์ฒญ์‹œ ์–ด๋–ค ์ •๋ณด๋ฅผ ์ „๋‹ฌ๋ฐ›์•˜๋Š”์ง€์— ๋Œ€ํ•œ request log๊ณผ

๊ทธ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ํƒœ์šด ๋’ค์— ์–ด๋–ค ์‘๋‹ต์„ ๋‚ด์ฃผ์—ˆ๋Š”์ง€

response log ๋งŒ ์žˆ์–ด๋„ ๋””๋ฒ„๊น…์€ ์ถฉ๋ถ„ํžˆ ๊ฐ€๋Šฅํ•˜์ฃ .

๋ฌผ๋ก  ์š”์ฒญ๊ณผ ์‘๋‹ต ์ค‘๊ฐ„์— ๋กœ์ง์ด ๋ณต์žกํ•˜๋‹ค๋ฉด ์ค‘๊ฐ„์ค‘๊ฐ„ ์ถ”๊ฐ€์ ์ธ ๋กœ๊ทธ๋ฅผ ์‹ฌ์–ด์ฃผ๋Š”๊ฒŒ ๋งŽ์€ ๋„์›€์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋ž˜์„œ ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์š”์ฒญ๊ณผ ์‘๋‹ต์„ ์–ด๋–ป๊ฒŒ ๋กœ๊น…ํ•˜๋Š”์ง€์— ๋Œ€ํ•ด ๊ณต์œ ๋“œ๋ฆฌ๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.

 

1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

 

๊ธฐ๋ณธ์ ์ธ ๊ฐœ๋ฐœํ™˜๊ฒฝ์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • IntelliJ IDEA 2021.3.3 (Ultimate Edition)
  • SpringBoot 2.7.3
  • Java 18 (OpenJDK)

์ž, ์šฐ์„  ๊นกํ†ต ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๊ฒ ์Šต๋‹ˆ๋‹ค.

์ž, ๊นกํ†ต ํ”„๋กœ์ ํŠธ๊ฐ€ ์™„์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. 

 

2. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€

์ด์ œ ๊ฐœ๋ฐœํŽธ์˜๋ฅผ ์œ„ํ•ด lombok๊ณผ ๋กœ๊น…์„ ์œ„ํ•œ logback ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , API ๊ฐœ๋ฐœ์„ ์œ„ํ•ด spring-boot-starter-web ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
implementation 'ch.qos.logback:logback-classic:1.2.11'

 

3. API ์ž‘์„ฑ

๊ทธ๋ฆฌ๊ณ  ์•„๋ž˜์™€ ๊ฐ™์ด ํ…Œ์ŠคํŠธ์šฉ ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ํ•˜๋‚˜ ์ž‘์„ฑํ•ด์ค๋‹ˆ๋‹ค.

package com.keichee.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/log")
    public int requestResponseLog(@RequestParam int code) {
        log.info("requestResponseLog method called with code {}", code);
        return code;
    }
}

 

์—ฌ๊ธฐ๊นŒ์ง€ํ•˜๊ณ  ์•ฑ์„ ๊ธฐ๋™ํ•œ ๋’ค API๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๋กœ๊ทธ๊ฐ€ ์ž˜ ๋‚จ๋Š”์ง€ ํ™•์ธํ•ด๋ณผ๊ฒŒ์š”.

2022-09-15 17:04:50.580  INFO 92637 --- [           main] com.keichee.demo.DemoLoggingApplication  : No active profile set, falling back to 1 default profile: "default"
2022-09-15 17:04:51.034  INFO 92637 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-09-15 17:04:51.038  INFO 92637 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-09-15 17:04:51.038  INFO 92637 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-09-15 17:04:51.105  INFO 92637 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-09-15 17:04:51.107  INFO 92637 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 495 ms
2022-09-15 17:04:51.306  INFO 92637 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-09-15 17:04:51.312  INFO 92637 --- [           main] com.keichee.demo.DemoLoggingApplication  : Started DemoLoggingApplication in 0.879 seconds (JVM running for 1.294)
2022-09-15 17:05:56.173  INFO 92637 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-09-15 17:05:56.173  INFO 92637 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-09-15 17:05:56.174  INFO 92637 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-09-15 17:05:56.186  INFO 92637 --- [nio-8080-exec-1] c.k.demo.controller.TestController       : requestResponseLog method called with code 2

 

์ œ์ผ ๋งˆ์ง€๋ง‰์ค„์— ๋ณด๋ฉด TestController์—์„œ ์ถœ๋ ฅํ•œ ๋กœ๊ทธ๊ฐ€ ๋ณด์ด๋„ค์š”.

๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์˜ ๋กœ๊ทธ๋Š” ์ž˜ ์ถœ๋ ฅ๋˜๊ณ  ์žˆ์œผ๋‹ˆ ์ด์ œ ๊ธฐ๋ณธ์ ์ธ ์ค€๋น„๊ฐ€ ๋๋‚ฌ์Šต๋‹ˆ๋‹ค.

 

4. Filter ๊ตฌํ˜„

์š”์ฒญ๊ณผ ์‘๋‹ต์— ๋Œ€ํ•œ ๋กœ๊ทธ์ถœ๋ ฅ์„ ์œ„ํ•ด์„œ ์šฐ๋ฆฌ๋Š” Filter๋ฅผ ์ด์šฉํ•  ๊ฒ๋‹ˆ๋‹ค. 

spring-web์—์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ filter๋ฅผ ์ œ๊ณตํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

AbstractRequestLoggingFilter
CharacterEncodingFilter
CommonsRequestLoggingFilter
CompositeFilter
CorsFilter
DelegatingFilterProxy
FormContentFilter
ForwardedHeaderFilter
GenericFilterBean
HiddenHttpMethodFilter
HttpPutFormContentFilter
OncePerRequestFilter
RelativeRedirectFilter
RelativeRedirectResponseWrapper
RequestContextFilter
ServletContextRequestLoggingFilter
ServletRequestPathFilter
ShallowEtagHeaderFilter

 

์—ฌ๊ธฐ์„œ request logging๊ณผ ๊ด€๋ จ๋œ filter๋Š” AbstractRequestLoggingFilter, CommonsRequestLoggingFilter, ๊ทธ๋ฆฌ๊ณ  ServletContextRequestLoggingFilter ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” AbstractRequestLoggingFilter๋ฅผ ์ƒ์†ํ•ด์„œ ์šฐ๋ฆฌ๋งŒ์˜ ํ•„ํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด ๋ณผ๊ฑฐ์—์š”.

com.keichee.demo ํŒจํ‚ค์ง€ ์•„๋ž˜์— filter ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค๊ณ  ์ด ์•ˆ์— RequestLoggingFilter ๋ผ๋Š” ํด๋ž˜์Šค๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”

package com.keichee.demo.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.AbstractRequestLoggingFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Slf4j
public class RequestLoggingFilter extends AbstractRequestLoggingFilter {

    @Override
    protected void beforeRequest(HttpServletRequest request, String message) {
        logger.info(message);
    }

    @Override
    protected void afterRequest(HttpServletRequest request, String message) {
        logger.info(message);
    }
}

 

์ด์ œ ์ด ํ•„ํ„ฐ๋ฅผ ๋นˆ์œผ๋กœ ๋“ฑ๋กํ•ด์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค.

com.keichee.demo ํŒจํ‚ค์ง€ ์•„๋ž˜์— config ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค๊ณ  ์ด ์•ˆ์— RequestLoggingConfig ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ฒ ์Šต๋‹ˆ๋‹ค.

package com.keichee.demo.config;

import com.keichee.demo.filter.RequestLoggingFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RequestLoggingConfig {

    public static int MAX_PAYLOAD_LENGTH = 1000;

    @Bean
    public RequestLoggingFilter loggingFilter() {
        RequestLoggingFilter filter = new RequestLoggingFilter();
        filter.setIncludeClientInfo(true);
        filter.setIncludeHeaders(false);
        filter.setIncludePayload(true);
        filter.setIncludeQueryString(true);
        filter.setMaxPayloadLength(MAX_PAYLOAD_LENGTH);
        return filter;
    }
}

 

ํ—ค๋”์ •๋ณด ๋กœ๊น…์ด ํ•„์š”ํ•  ๊ฒฝ์šฐ setIncludeHeaders(true)๋กœ ์„ค์ •ํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

payload์˜ max length๋Š” ๋กœ๊น…๋Ÿ‰๊ณผ ๋กœ๊ทธ๋ฅผ ์ €์žฅํ•˜๋Š” ์‹œ์Šคํ…œ์˜ ์šฉ๋Ÿ‰ ๋“ฑ์— ๋”ฐ๋ผ ์ ๋‹นํžˆ ์„ค์ •ํ•ด์ฃผ์‹œ๋ฉด๋ฉ๋‹ˆ๋‹ค. 

 

์ด์ œ ๋งˆ์ง€๋ง‰ ํ•œ์Šคํ…์ด ๋‚จ์•˜์Šต๋‹ˆ๋‹ค.

logback-spring.xml ํŒŒ์ผ์„ resources ๋””๋ ‰ํ† ๋ฆฌ์— ์ถ”๊ฐ€ํ•ด์ค๋‹ˆ๋‹ค.

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

    <springProfile name="local">
        <logger name="com.keichee.demo" level="debug" additivity="false">
            <appender-ref ref="CONSOLE"/>
        </logger>

        <root level="error">
            <appender-ref ref="CONSOLE"/>
        </root>
    </springProfile>

</configuration>

 

์ง€๊ธˆ๊นŒ์ง€ ์ž‘์„ฑํ•œ ํŒŒ์ผ๋“ค์„ ํฌํ•จํ•˜์—ฌ ์ตœ์ข…์ ์œผ๋กœ ํŒจํ‚ค์ง€ ํŠธ๋ฆฌ๋ฅผ ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ด์ œ active profile ๊ฐ’์— local ์„ ์ฃผ๊ณ  ์•ฑ์„ ์žฌ๊ธฐ๋™ํ•œ๋’ค ํ•„ํ„ฐ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ ์šฉ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

2022-09-16 07:28:54.399 DEBUG 31518 --- [           main] com.keichee.demo.DemoLoggingApplication  : Running with Spring Boot v2.7.3, Spring v5.3.22
2022-09-16 07:28:54.399  INFO 31518 --- [           main] com.keichee.demo.DemoLoggingApplication  : The following 1 profile is active: "local"
2022-09-16 07:28:54.751 DEBUG 31518 --- [           main] c.k.demo.filter.RequestLoggingFilter     : Filter 'loggingFilter' configured for use
2022-09-16 07:28:54.866  INFO 31518 --- [           main] com.keichee.demo.DemoLoggingApplication  : Started DemoLoggingApplication in 0.607 seconds (JVM running for 0.819)

์ถœ๋ ฅ๋˜๋Š” ๋กœ๊ทธ ์ค‘์— Filter 'loggingFilter' configured for use ๊ฐ€ ์ถœ๋ ฅ๋œ๊ฑธ๋กœ ๋ณด์•„ ์ •์ƒ์ ์œผ๋กœ ์ ์šฉ์ด ๋œ ๊ฒƒ์œผ๋กœ ํ™•์ธ๋ฉ๋‹ˆ๋‹ค.

 

์ด์ œ ๊ธฐ์กด์— ๋งŒ๋“ค์–ด ๋‘์—ˆ๋˜ API๋ฅผ ๋‹ค์‹œ ํ˜ธ์ถœํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

2022-09-16 07:29:18.541  INFO 31518 --- [nio-8080-exec-2] c.k.demo.filter.RequestLoggingFilter     : Before request [GET /test/log?code=2, client=0:0:0:0:0:0:0:1]
2022-09-16 07:29:18.550  INFO 31518 --- [nio-8080-exec-2] c.k.demo.controller.TestController       : requestResponseLog method called with code 2
2022-09-16 07:29:18.560  INFO 31518 --- [nio-8080-exec-2] c.k.demo.filter.RequestLoggingFilter     : After request [GET /test/log?code=2, client=0:0:0:0:0:0:0:1]

์š”์ฒญ์— ๋Œ€ํ•œ ์ •๋ณด uri์™€ query parameter ๊ทธ๋ฆฌ๊ณ  client์— X-Forwarded-For ๊ฐ’์ด ์ถœ๋ ฅ๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๊ณ , ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ์‹คํ–‰์ด ๋๋‚œ ๋’ค ์†Œ์š”์‹œ๊ฐ„์ด ์–ผ๋งˆ์ธ์ง€ http status ๊ฐ’์ด ๋ญ”์ง€ ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ง€๊ธˆ๊นŒ์ง€ ์š”์ฒญ์— ๋Œ€ํ•œ uri, query parameter์™€ API๋ฅผ ์š”์ฒญํ•œ ํด๋ผ์ด์–ธํŠธ์˜ IP ๋ฅผ ์ถœ๋ ฅํ•˜๊ณ ,

์‘๋‹ต์„ ์ฃผ๊ธฐ๊นŒ์ง€์˜ ์†Œ์š”์‹œ๊ฐ„๊ณผ ์‘๋‹ต ์ƒํƒœ๊ฐ’์„ ๋กœ๊น…ํ•˜๋„๋ก ์„ค์ •์„ ํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ๊นŒ์ง€ ์ž˜ ๋”ฐ๋ผ ์˜ค์…จ๋‚˜์š”? ๐Ÿ˜‹

 

์ด์ œ request body ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ payload๊ฐ€ ์ž˜ ์ถœ๋ ฅ๋˜๋Š”์ง€ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

TestController ์— request body๋ฅผ ๋ฐ›๋Š” API๋ฅผ ํ•˜๋‚˜ ์ถ”๊ฐ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

@PostMapping("/request-body-log")
public long requestBodyLog(@RequestBody Employee employee) {
    return employee.getId();
}

Employee ์ •๋ณด๋ฅผ ๋ฐ›์•„์„œ id๋ฅผ ๊ทธ๋Œ€๋กœ ๋ฆฌํ„ดํ•ด์ฃผ๋Š” ๊ฐ„๋‹จํ•œ API์ž…๋‹ˆ๋‹ค. (์–ด์ฐจํ”ผ request body ๋กœ๊น…์„ ์œ„ํ•œ๊ฑฐ๋‹ˆ ์‹ฌํ”Œํ•˜๊ฒŒ 

 

๊ทธ๋ฆฌ๊ณ  domain ํŒจํ‚ค์ง€ ํ•˜์œ„์— Employee ํด๋ž˜์Šค๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ์ƒ์„ฑํ•ด์ฃผ๊ฒ ์Šต๋‹ˆ๋‹ค.

@Getter
@Setter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Employee {
    long id;
    String name;
    int age;
}

 

์ด์ œ  ์•ฑ์„ ๊ธฐ๋™ํ•ด์„œ postman์œผ๋กœ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

๋กœ๊ทธ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ถœ๋ ฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

2022-09-16 07:32:49.190  INFO 31518 --- [nio-8080-exec-5] c.k.demo.filter.RequestLoggingFilter     : Before request [POST /test/request-body-log, client=0:0:0:0:0:0:0:1]
2022-09-16 07:32:49.226  INFO 31518 --- [nio-8080-exec-5] c.k.demo.filter.RequestLoggingFilter     : After request [POST /test/request-body-log, client=0:0:0:0:0:0:0:1, payload={
    "id":1000,
    "name":"์ผ€์ด์น˜",
    "age":20
}]

 

๊ทธ๋Ÿฐ๋ฐ ๋กœ๊ทธ๋ฅผ ๋ณด๋‹ˆ uri ์ •๋ณด์™€ client ์ •๋ณด๊ฐ€ ์ค‘๋ณต๋˜์„œ ์ถœ๋ ฅ์ด ๋˜๊ณ  ์žˆ๊ณ , request body๋กœ ๋„˜๊ฒจ์ค€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ๋ชจ๋‘ ์‹คํ–‰๋˜๊ณ  ๋‚œ ๋’ค์— ์ถœ๋ ฅ๋˜๋Š” After request ... ๋ถ€๋ถ„์— ์ถœ๋ ฅ์ด ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ญ”๊ฐ€ ์ถœ๋ ฅ๋˜๋Š” ๋‚ด์šฉ์ด ๋งˆ์Œ์— ๋“ค์ง€ ์•Š๋„ค์š”. 

 

๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ๋Š” ๋กœ๊ทธ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ”๊ฟ”๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค~ ๐Ÿ™‡

 

๋„์›€์ด ๋˜์…จ๋‹ค๋ฉด ์ข‹์•„์š” ๊พน ๋ˆŒ๋Ÿฌ์ฃผ๊ณ  ๊ฐ€์„ธ์š”~

 

[ ๋‹ค์Œ ํฌ์ŠคํŒ… ๋ฐ”๋กœ ์ฝ๊ธฐ ]

 

[5๋ถ„์ฝ”๋”ฉ] Filter๋ฅผ ์ด์šฉํ•œ ์š”์ฒญ,์‘๋‹ต ๋กœ๊น… (How to log request, response info inlcuding payload using filter) - (2/2)

์ง€๋‚œ ํฌ์ŠคํŒ…์—์„œ ์š”์ฒญ๊ณผ ์‘๋‹ต์— ๋Œ€ํ•œ ๋กœ๊ทธ๋ฅผ ๋‚จ๊ธฐ๋Š” ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์•˜์—ˆ๋Š”๋ฐ์š” ์ด์–ด์„œ ์ด๋ฒˆ์—๋Š” ์ถœ๋ ฅ๋˜๋Š” ๋กœ๊ทธ๋ฉ”์‹œ์ง€์˜ ๋‚ด์šฉ์„ ๋‚ด๋ง˜๋Œ€๋กœ ๋ฐ”๊ฟ”๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ํ˜น์‹œ๋ผ๋„ ๊ฒ€์ƒ‰์œผ๋กœ ์ด ํฌ์ŠคํŒ…

keichee.tistory.com