diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2022-09-22 10:41:54 +0100 |
---|---|---|
committer | Fiachra Corcoran <fiachra.corcoran@est.tech> | 2022-11-03 14:28:09 +0000 |
commit | 314df904244f02122c011803e15012fc9dee2251 (patch) | |
tree | 8f52f75f38b0c5f6712db533f1013ea9b417aaae /kubernetes/cps/components/cps-core | |
parent | 8778cc162677eac7d2db8302f035efc37878fdec (diff) |
[CPS] Security logging fields
- Removed the old logback.xml file.
- Added logback-spring.xml with the new format for logging in json
format
- Updated the file mount path in deployment file.
- Above change is just for CPS-Core
Issue-ID: CPS-1291
Change-Id: If1b657a4959023fc18d0a4710891a55dfeb29b22
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'kubernetes/cps/components/cps-core')
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 |