shivasubedi | 8df61a9 | 2021-06-16 14:43:18 +0100 | [diff] [blame] | 1 | <!-- |
| 2 | ============LICENSE_START======================================================= |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 3 | Copyright (C) 2021-2022 Nordix Foundation |
shivasubedi | 8df61a9 | 2021-06-16 14:43:18 +0100 | [diff] [blame] | 4 | ================================================================================ |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
lukegleeson | 15b93e7 | 2021-07-07 15:25:30 +0100 | [diff] [blame] | 16 | |
| 17 | SPDX-License-Identifier: Apache-2.0 |
shivasubedi | 8df61a9 | 2021-06-16 14:43:18 +0100 | [diff] [blame] | 18 | ============LICENSE_END========================================================= |
| 19 | --> |
| 20 | |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 21 | <configuration scan="true" scanPeriod="30 seconds" debug="false"> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 22 | |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 23 | <include resource="org/springframework/boot/logging/logback/defaults.xml" /> |
| 24 | <include resource="org/springframework/boot/logging/logback/console-appender.xml" /> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 25 | |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 26 | <springProperty scope="context" name="springAppName" source="spring.application.name"/> |
| 27 | <springProperty scope="context" name="username" source="security.auth.username"/> |
| 28 | <springProperty scope="context" name="loggingFormat" source="logging.format"/> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 29 | |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 30 | <property name="currentTimeStamp" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}"/> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 31 | |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 32 | <appender name="jsonConsole" |
| 33 | class="ch.qos.logback.core.ConsoleAppender"> |
| 34 | <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"> |
| 35 | <providers> |
| 36 | <pattern> |
| 37 | <omitEmptyFields>true</omitEmptyFields> |
| 38 | <pattern> |
| 39 | { |
| 40 | "logTimeStamp": "${currentTimeStamp:-}", |
| 41 | "logTypeName": "", |
| 42 | "logLevel": "%level", |
| 43 | "traceId": "%X{traceId:-}", |
| 44 | "statusCode": "", |
| 45 | "principalId": "${username:-}", |
| 46 | "serviceName": "${springAppName:-}", |
| 47 | "message": "%message", |
| 48 | "spanId": "%X{spanId:-}", |
| 49 | "processId": "${PID:-}", |
| 50 | "threadName": "%thread", |
| 51 | "class": "%logger{40}", |
| 52 | "exception": "%wEx" |
| 53 | } |
| 54 | </pattern> |
| 55 | </pattern> |
| 56 | </providers> |
| 57 | </encoder> |
| 58 | </appender> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 59 | |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 60 | <appender name="asyncConsole" class="ch.qos.logback.classic.AsyncAppender"> |
sourabh_sourabh | e4f3b39 | 2022-05-06 11:31:54 +0100 | [diff] [blame] | 61 | <if condition='property("loggingFormat").equalsIgnoreCase("json")'> |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 62 | <then> |
| 63 | <appender-ref ref="jsonConsole"/> |
| 64 | </then> |
| 65 | <else> |
| 66 | <appender-ref ref="CONSOLE"/> |
| 67 | </else> |
| 68 | </if> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 69 | </appender> |
| 70 | |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 71 | <root level="INFO"> |
sourabh_sourabh | ac5ae3e | 2022-04-22 22:47:41 +0100 | [diff] [blame] | 72 | <appender-ref ref="asyncConsole"/> |
Rishi Chail | b220d74 | 2020-09-16 15:23:53 +0100 | [diff] [blame] | 73 | </root> |
| 74 | |
lukegleeson | 15b93e7 | 2021-07-07 15:25:30 +0100 | [diff] [blame] | 75 | </configuration> |