From: sourabh_sourabh Date: Wed, 4 May 2022 10:53:01 +0000 (+0100) Subject: Security Logging Fields X-Git-Tag: 1.2.0~7 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=a7863efca29d19ea07b3cdbad23e2b4335694c97;p=cps%2Fcps-temporal.git 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: I9e45a9d842831a87af3fb9ac309485110357f0c8 --- diff --git a/pom.xml b/pom.xml index 9b6612f..a2931f7 100755 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,11 @@ pom import + + org.springframework.cloud + spring-cloud-starter-sleuth + 3.1.1 + org.spockframework spock-bom @@ -73,6 +78,21 @@ pom import + + net.logstash.logback + logstash-logback-encoder + 7.0.1 + + + org.codehaus.janino + janino + 3.1.7 + + + com.vladmihalcea + hibernate-types-52 + 2.10.0 + @@ -104,7 +124,6 @@ com.vladmihalcea hibernate-types-52 - 2.10.0 org.liquibase @@ -206,6 +225,18 @@ 0.18.0 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 7db9510..9b3be03 100755 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -25,6 +25,8 @@ rest: base-path: /cps-temporal/api spring: + application: + name: cps-temporal datasource: url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/cpstemporaldb username: ${DB_USERNAME} @@ -90,4 +92,8 @@ management: show-details: always # kubernetes probes: liveness and readiness probes: - enabled: true \ No newline at end of file + enabled: true + +logging: + format: json + \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..c71c9a6 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + 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/main/resources/logback.xml b/src/main/resources/logback.xml deleted file mode 100644 index a75b7aa..0000000 --- a/src/main/resources/logback.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - %d - %highlight(%-5level) [%-20.20thread] %cyan(%logger{36}) - %msg%n - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 9bdacbe..ce0e95b 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -24,6 +24,8 @@ rest: base-path: /cps-temporal/api spring: + application: + name: cps-temporal datasource: url: ${DB_URL} username: ${DB_USERNAME} @@ -71,3 +73,6 @@ security: auth: username: testUser password: testPassword + +logging: + format: json