summaryrefslogtreecommitdiff
path: root/sw-server/src/main/resources/logback-spring.xml
blob: afb338bd60e740b9cad80d6e29fd1505ff3bf4b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>

    <appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
        <!-- Loki Cloud hosted solution is limiting the batch size to 65536 Bytes -->
        <batchMaxBytes>65536</batchMaxBytes>
        <batchTimeoutMs>10000</batchTimeoutMs>
        <metricsEnabled>true</metricsEnabled>
        <http>
            <url>https://logs-prod-us-central1.grafana.net/loki/api/v1/push</url>
            <auth>
                <username>${LOKI_USERNAME}</username>
                <password>${LOKI_PASSWORD}</password>
            </auth>
            <requestTimeoutMs>15000</requestTimeoutMs>
        </http>
        <format>
            <label>
                <pattern>application=seven-wonders,instance=${HOSTNAME},level=%level,class=%logger</pattern>
            </label>
            <message>
                <pattern>timestamp=%date level=%level class=%logger thread=%thread | %msg %ex</pattern>
            </message>
        </format>
    </appender>

    <springProfile name="prod">
        <root level="INFO">
            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="LOKI"/>
        </root>
    </springProfile>

    <springProfile name="!prod">
        <root level="DEBUG">
            <appender-ref ref="CONSOLE"/>
        </root>
        <logger name="org.springframework" level="INFO" additivity="false">
            <appender-ref ref="CONSOLE" />
        </logger>
    </springProfile>

</configuration>
bgstack15