blob: 03076023b370c9317ff28d0e93ec753e31488256 [file] [log] [blame]
shivasubedi8df61a92021-06-16 14:43:18 +01001<!--
2 ============LICENSE_START=======================================================
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +01003 Copyright (C) 2021-2022 Nordix Foundation
shivasubedi8df61a92021-06-16 14:43:18 +01004 ================================================================================
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.
lukegleeson15b93e72021-07-07 15:25:30 +010016
17 SPDX-License-Identifier: Apache-2.0
shivasubedi8df61a92021-06-16 14:43:18 +010018 ============LICENSE_END=========================================================
19-->
20
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010021<configuration scan="true" scanPeriod="30 seconds" debug="false">
Rishi Chailb220d742020-09-16 15:23:53 +010022
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010023 <include resource="org/springframework/boot/logging/logback/defaults.xml" />
24 <include resource="org/springframework/boot/logging/logback/console-appender.xml" />
Rishi Chailb220d742020-09-16 15:23:53 +010025
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010026 <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 Chailb220d742020-09-16 15:23:53 +010029
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010030 <property name="currentTimeStamp" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}"/>
Rishi Chailb220d742020-09-16 15:23:53 +010031
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010032 <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 Chailb220d742020-09-16 15:23:53 +010059
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010060 <appender name="asyncConsole" class="ch.qos.logback.classic.AsyncAppender">
sourabh_sourabhe4f3b392022-05-06 11:31:54 +010061 <if condition='property("loggingFormat").equalsIgnoreCase("json")'>
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010062 <then>
63 <appender-ref ref="jsonConsole"/>
64 </then>
65 <else>
66 <appender-ref ref="CONSOLE"/>
67 </else>
68 </if>
Rishi Chailb220d742020-09-16 15:23:53 +010069 </appender>
70
Rishi Chailb220d742020-09-16 15:23:53 +010071 <root level="INFO">
sourabh_sourabhac5ae3e2022-04-22 22:47:41 +010072 <appender-ref ref="asyncConsole"/>
Rishi Chailb220d742020-09-16 15:23:53 +010073 </root>
74
lukegleeson15b93e72021-07-07 15:25:30 +010075</configuration>