From beb6c619e5b4cfd8fc0010130722cf82cc80931c Mon Sep 17 00:00:00 2001 From: woozu-shin Date: Tue, 10 Oct 2023 20:42:41 +0900 Subject: [PATCH] [NO-ISSUE] Add applicationName property --- .../sample/configuration/logging/LoggingInterceptor.java | 6 ++++-- .../sample/configuration/logging/LoggingProperties.java | 1 + src/main/resources/application.yaml | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) 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 d1e408c..342e7d5 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 @@ -23,12 +23,14 @@ public class LoggingInterceptor implements HandlerInterceptor { private final LogPersistenceService logPersistenceService; private final LoggingProperties.HttpMethod httpMethodProperties; private final LoggingProperties.HttpStatus httpStatusProperties; + private final String applicationName; public LoggingInterceptor(LogPersistenceService logPersistenceService, LoggingProperties loggingProperties) { this.logPersistenceService = logPersistenceService; this.httpMethodProperties = loggingProperties.getHttpMethod(); this.httpStatusProperties = loggingProperties.getHttpStatus(); + this.applicationName = loggingProperties.getApplicationName(); } @Override @@ -42,7 +44,7 @@ public class LoggingInterceptor implements HandlerInterceptor { .body(getBodyIfAvailable(request)) .requestedAt(Instant.now()) .traceId(MDC.get("traceId")) - .applicationName("myoa-engineering-logging-sample") + .applicationName(applicationName) .build(); loggingRequest(requestLog); logPersistenceService.save(requestLog); @@ -91,7 +93,7 @@ public class LoggingInterceptor implements HandlerInterceptor { .body(getBodyIfAvailable(response)) .respondedAt(Instant.now()) .traceId(MDC.get("traceId")) - .applicationName("myoa-engineering-logging-sample") + .applicationName(applicationName) .build(); loggingResponse(responseLog); logPersistenceService.save(responseLog); diff --git a/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingProperties.java b/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingProperties.java index 0b39374..66b398e 100644 --- a/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingProperties.java +++ b/src/main/java/com/myoa/engineering/sample/configuration/logging/LoggingProperties.java @@ -14,6 +14,7 @@ public class LoggingProperties { private HttpMethod httpMethod; private HttpStatus httpStatus; + private String applicationName; @Getter @Setter diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 33cd5cd..0916ed6 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -21,6 +21,7 @@ logging: org.hibernate.SQL: DEBUG org.hibernate.type.descriptor.sql: TRACE web: + application-name: myoa-engineering-logging-sample http-method: excludes: - GET