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