diff options
author | 2022-09-22 10:41:54 +0100 | |
---|---|---|
committer | 2022-11-03 14:28:09 +0000 | |
commit | 314df904244f02122c011803e15012fc9dee2251 (patch) | |
tree | 8f52f75f38b0c5f6712db533f1013ea9b417aaae /kubernetes/cps/components/cps-core/resources/config/logback-spring.xml | |
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/resources/config/logback-spring.xml')
-rw-r--r-- | kubernetes/cps/components/cps-core/resources/config/logback-spring.xml | 75 |
1 files changed, 75 insertions, 0 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> |