2.9 KiB
2.9 KiB
LoggingTestAPIController.java
logging test - get w/ body
curl -X GET 'http://localhost:20090/api/v1/loggingTest/getWithBody' \
--header 'Content-Type: application/json' \
--data '{
"value1" : "v1!",
"value2" : 123,
"value3" : false
}'
logging test - get w/ param
curl http://localhost:20090/api/v1/loggingTest/get?p1=v1&p2=v2
logging test - post w/o body, w/ error
curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody'
logging test - post w/ body
curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody' \
--header 'Content-Type: application/json' \
--data '{
"value1" : "valu1!",
"value2" : 1111111,
"value3" : true
}'
Appendix
schema.sql for other dbms
mysql
create table request_log
(
id bigint auto_increment primary key,
application_name varchar(64),
http_method varchar(255),
uri varchar(255),
query_string varchar(2047),
content_type varchar(255),
body mediumtext,
requested_at timestamp(6),
trace_id varchar(40),
created_at timestamp(6),
primary key (id)
);
create table response_log
(
id bigint auto_increment primary key,
application_name varchar(64),
http_status integer,
content_type varchar(255),
body mediumtext,
responded_at timestamp(6),
trace_id varchar(40),
created_at timestamp(6),
primary key (id)
);
postgresql
create table request_log
(
id bigint generated by default as identity primary key,
application_name varchar(64),
http_method varchar(255),
uri varchar(255),
query_string varchar(255),
content_type varchar(255),
body text,
requested_at timestamp(6) with time zone,
trace_id varchar(40),
created_at timestamp(6) with time zone
);
create table response_log
(
id bigint generated by default as identity primary key,
application_name varchar(64),
http_status integer,
content_type varchar(255),
body text,
responded_at timestamp(6) with time zone,
trace_id varchar(40),
created_at timestamp(6) with time zone
);
References
- https://daakludens.github.io/spring/filter-vs-interceptor/ Filter와 Interceptor를 제대로 구분해 사용하는 법
- https://bamdule.tistory.com/149
- [SpringBoot] HandlerInterceptor 설정하기
- https://mopil.tistory.com/74
- [Spring Boot] Request body, Response body 로깅 하는 법 (with 코틀린)
- https://oops4u.tistory.com/2602
- Request / Response Body Logging
- https://xzio.tistory.com/1999
- [Spring 프로젝트] Interceptor로 request, response body json 값 로깅하기