[NO-ISSUE] Add column

This commit is contained in:
woozu-shin 2023-10-10 19:27:51 +09:00
parent 8d078ebb10
commit f4ffd2ec4e
4 changed files with 46 additions and 38 deletions

View File

@ -1,8 +1,7 @@
## `LoggingTestAPIController.java`
### logging test - get w/ body
```shell
curl -X GET 'http://localhost:20090/api/v1/loggingTest/getWithBody' \
--header 'Content-Type: application/json' \
@ -15,19 +14,19 @@ curl -X GET 'http://localhost:20090/api/v1/loggingTest/getWithBody' \
```
### logging test - get w/ param
```shell
curl http://localhost:20090/api/v1/loggingTest/get?p1=v1&p2=v2
```
### logging test - post w/o body, w/ error
```shell
curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody'
```
### logging test - post w/ body
```shell
curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody' \
--header 'Content-Type: application/json' \
@ -38,63 +37,68 @@ curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody' \
}'
```
# Appendix
## schema.sql for other dbms
### mysql
```mysql
create table request_log
(
id bigint auto_increment primary key,
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),
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,
http_status integer,
content_type varchar(255),
body mediumtext,
responded_at timestamp(6),
trace_id varchar(40),
created_at timestamp(6),
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
```postgresql
create table request_log
(
id bigint generated by default as identity primary key,
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
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,
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
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
);
```

View File

@ -37,6 +37,7 @@ public class LoggingInterceptor implements HandlerInterceptor {
.body(getBodyIfAvailable(request))
.requestedAt(Instant.now())
.traceId(MDC.get("traceId"))
.applicationName("myoa-engineering-logging-sample")
.build();
loggingRequest(requestLog);
logPersistenceService.save(requestLog);
@ -82,6 +83,7 @@ public class LoggingInterceptor implements HandlerInterceptor {
.body(getBodyIfAvailable(response))
.respondedAt(Instant.now())
.traceId(MDC.get("traceId"))
.applicationName("myoa-engineering-logging-sample")
.build();
loggingResponse(responseLog);
logPersistenceService.save(responseLog);

View File

@ -18,6 +18,7 @@ public class RequestLog extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String applicationName;
private String httpMethod;
private String uri;
private String queryString;

View File

@ -18,6 +18,7 @@ public class ResponseLog extends Auditable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String applicationName;
private Integer httpStatus;
private String contentType;
private String body;