[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,16 +37,17 @@ 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,
application_name varchar(64),
http_method varchar(255),
uri varchar(255),
query_string varchar(2047),
@ -62,6 +62,7 @@ create table request_log
create table response_log
(
id bigint auto_increment primary key,
application_name varchar(64),
http_status integer,
content_type varchar(255),
body mediumtext,
@ -73,10 +74,12 @@ create table response_log
```
### postgresql
```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),
@ -90,6 +93,7 @@ create table request_log
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,

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;