aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes
diff options
context:
space:
mode:
authorFiachra Corcoran <fiachra.corcoran@est.tech>2022-11-04 13:40:53 +0000
committerGerrit Code Review <gerrit@onap.org>2022-11-04 13:40:53 +0000
commite63ce719d349ff5c8000d52a3a097a1f1d598a7c (patch)
treebce0bf5c86ee2525f1c958725f033fd45918cec9 /kubernetes
parent384deaa222b4d588314a3fa29cad1032e3204d69 (diff)
parent314df904244f02122c011803e15012fc9dee2251 (diff)
Merge "[CPS] Security logging fields"
Diffstat (limited to 'kubernetes')
-rw-r--r--kubernetes/cps/components/cps-core/resources/config/logback-spring.xml75
-rw-r--r--kubernetes/cps/components/cps-core/resources/config/logback.xml36
-rw-r--r--kubernetes/cps/components/cps-core/templates/deployment.yaml4
3 files changed, 77 insertions, 38 deletions
diff --git a/kubernetes/cps/components/cps-core/resources/config/logback-spring.xml b/kubernetes/cps/components/cps-core/resources/config/logback-spring.xml
new file mode 100644
index 0000000000..03076023b3
--- /dev/null
+++ b/kubernetes/cps/components/cps-core/resources/config/logback-spring.xml
@@ -0,0 +1,75 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2021-2022 Nordix Foundation
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
+
+ <include resource="org/springframework/boot/logging/logback/defaults.xml" />
+ <include resource="org/springframework/boot/logging/logback/console-appender.xml" />
+
+ <springProperty scope="context" name="springAppName" source="spring.application.name"/>
+ <springProperty scope="context" name="username" source="security.auth.username"/>
+ <springProperty scope="context" name="loggingFormat" source="logging.format"/>
+
+ <property name="currentTimeStamp" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}"/>
+
+ <appender name="jsonConsole"
+ class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
+ <providers>
+ <pattern>
+ <omitEmptyFields>true</omitEmptyFields>
+ <pattern>
+ {
+ "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"
+ }
+ </pattern>
+ </pattern>
+ </providers>
+ </encoder>
+ </appender>
+
+ <appender name="asyncConsole" class="ch.qos.logback.classic.AsyncAppender">
+ <if condition='property("loggingFormat").equalsIgnoreCase("json")'>
+ <then>
+ <appender-ref ref="jsonConsole"/>
+ </then>
+ <else>
+ <appender-ref ref="CONSOLE"/>
+ </else>
+ </if>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="asyncConsole"/>
+ </root>
+
+</configuration>
diff --git a/kubernetes/cps/components/cps-core/resources/config/logback.xml b/kubernetes/cps/components/cps-core/resources/config/logback.xml
deleted file mode 100644
index 8256cfa18d..0000000000
--- a/kubernetes/cps/components/cps-core/resources/config/logback.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2020 Bell Canada.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- SPDX-License-Identifier: Apache-2.0
- ============LICENSE_END=========================================================
--->
-
-<configuration scan="true" scanPeriod="30 seconds" debug="false">
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d - %highlight(%-5level) [%-20.20thread] %cyan(%logger{36}) - %msg%n</pattern>
- </encoder>
- </appender>
- <appender name="AsyncSysOut" class="ch.qos.logback.classic.AsyncAppender">
- <appender-ref ref="STDOUT" />
- </appender>
-
- <root level="INFO">
- <appender-ref ref="AsyncSysOut" />
- </root>
-
-</configuration>
-
diff --git a/kubernetes/cps/components/cps-core/templates/deployment.yaml b/kubernetes/cps/components/cps-core/templates/deployment.yaml
index 1b482f405c..3684aab3ac 100644
--- a/kubernetes/cps/components/cps-core/templates/deployment.yaml
+++ b/kubernetes/cps/components/cps-core/templates/deployment.yaml
@@ -126,8 +126,8 @@ spec:
- mountPath: /app/resources/application-helm.yml
subPath: application-helm.yml
name: init-data
- - mountPath: /app/resources/logback.xml
- subPath: logback.xml
+ - mountPath: /app/resources/logback-spring.xml
+ subPath: logback-spring.xml
name: init-data
- mountPath: /tmp
name: init-temp