From df26bc38a75f10650ce5785cdc9bd7b9516f6f25 Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Wed, 4 May 2022 11:38:52 +0100 Subject: Security Logging Fields - logback encoder and sleuth dependencies are added. - New appender is added to log JSON format content on console. Issue-ID: CPS-986 Signed-off-by: sourabh_sourabh Change-Id: Id7e4d836188da54b94144076a8755e4a2643a7ad --- pom.xml | 22 ++++++++++ src/main/resources/application.yml | 3 ++ src/main/resources/logback-spring.xml | 75 +++++++++++++++++++++++++++++++++++ src/test/resources/application.yml | 4 ++ 4 files changed, 104 insertions(+) create mode 100644 src/main/resources/logback-spring.xml diff --git a/pom.xml b/pom.xml index 33354123..d18acff4 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,16 @@ pom import + + net.logstash.logback + logstash-logback-encoder + 7.0.1 + + + org.codehaus.janino + janino + 3.1.7 + @@ -185,6 +195,18 @@ kafka test + + org.springframework.cloud + spring-cloud-starter-sleuth + + + net.logstash.logback + logstash-logback-encoder + + + org.codehaus.janino + janino + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 71a689cd..8be97d2d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -39,6 +39,8 @@ security: # This is a known issue with springfox and springboot introduced in 2.6.x: # https://github.com/springfox/springfox/issues/3462 spring: + application: + name: ncmp-dmi-plugin mvc: pathmatch: matching-strategy: ANT_PATH_MATCHER @@ -89,6 +91,7 @@ sdnc: password: ${SDNC_PASSWORD} logging: + format: json level: org.springframework: ERROR org.onap.cps: DEBUG diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..355209b4 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + true + + { + "logTimeStamp": "${currentTimeStamp:-}", + "logTypeName": "", + "logLevel": "%level", + "traceId": "%X{traceId:-}", + "statusCode": "", + "principalId": "${username:-}", + "serviceName": "${springAppName:-}", + "message": "%message", + "spanId": "%X{spanId:-}", + "processId": "${PID:-}", + "threadName": "%thread", + "class": "%logger{40}", + "exception": "%wEx" + } + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index afaaa4d6..0d3784f9 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -45,6 +45,8 @@ dmi: url: some url for the dmi service spring: + application: + name: ncmp-dmi-plugin kafka: bootstrap-servers: localhost:9092 security: @@ -59,3 +61,5 @@ app: async-m2m: topic: my-topic-name +logging: + format: json -- cgit 1.2.3-korg