example for spring boot request, response logging
Go to file
woozu-shin beb6c619e5 [NO-ISSUE] Add applicationName property 2023-10-10 20:42:41 +09:00
gradle/wrapper [NO-ISSUE] Initialize project 2023-10-10 18:08:44 +09:00
src [NO-ISSUE] Add applicationName property 2023-10-10 20:42:41 +09:00
.gitignore [NO-ISSUE] Initialize project 2023-10-10 18:08:44 +09:00
README.md [NO-ISSUE] Add column 2023-10-10 19:27:51 +09:00
build.gradle [NO-ISSUE] Initialize project 2023-10-10 18:08:44 +09:00
gradlew [NO-ISSUE] Initialize project 2023-10-10 18:08:44 +09:00
gradlew.bat [NO-ISSUE] Initialize project 2023-10-10 18:08:44 +09:00
settings.gradle [NO-ISSUE] Initialize project 2023-10-10 18:08:44 +09:00

README.md

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
);