diff --git a/README.md b/README.md index 1f0294d..15afcf3 100644 --- a/README.md +++ b/README.md @@ -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 ); ``` \ No newline at end of file diff --git a/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingInterceptor.java b/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingInterceptor.java index 96dedb9..7333452 100644 --- a/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingInterceptor.java +++ b/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingInterceptor.java @@ -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); diff --git a/src/main/java/com/myoa/engineering/sample/entity/RequestLog.java b/src/main/java/com/myoa/engineering/sample/entity/RequestLog.java index 27c36f3..be9563e 100644 --- a/src/main/java/com/myoa/engineering/sample/entity/RequestLog.java +++ b/src/main/java/com/myoa/engineering/sample/entity/RequestLog.java @@ -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; diff --git a/src/main/java/com/myoa/engineering/sample/entity/ResponseLog.java b/src/main/java/com/myoa/engineering/sample/entity/ResponseLog.java index d46546c..fad8f48 100644 --- a/src/main/java/com/myoa/engineering/sample/entity/ResponseLog.java +++ b/src/main/java/com/myoa/engineering/sample/entity/ResponseLog.java @@ -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;