summaryrefslogtreecommitdiff
path: root/sw-server/src/main/resources/logback-spring.xml
diff options
context:
space:
mode:
authorjoffrey-bion <joffrey.bion@gmail.com>2021-02-14 03:05:23 +0100
committerjoffrey-bion <joffrey.bion@gmail.com>2021-02-14 03:08:37 +0100
commita8a2dc9b50eb9f0c067a4524cde9e8a458d5657f (patch)
tree56e9b7e6f464f86d92c28279197c00d294d30ab2 /sw-server/src/main/resources/logback-spring.xml
parentAdd timestamp to logs (diff)
downloadseven-wonders-a8a2dc9b50eb9f0c067a4524cde9e8a458d5657f.tar.gz
seven-wonders-a8a2dc9b50eb9f0c067a4524cde9e8a458d5657f.tar.bz2
seven-wonders-a8a2dc9b50eb9f0c067a4524cde9e8a458d5657f.zip
Use profiles to avoid sending local logs to Loki
Diffstat (limited to 'sw-server/src/main/resources/logback-spring.xml')
-rw-r--r--sw-server/src/main/resources/logback-spring.xml47
1 files changed, 47 insertions, 0 deletions
diff --git a/sw-server/src/main/resources/logback-spring.xml b/sw-server/src/main/resources/logback-spring.xml
new file mode 100644
index 00000000..07b9e58e
--- /dev/null
+++ b/sw-server/src/main/resources/logback-spring.xml
@@ -0,0 +1,47 @@
+<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.InstrumentedLoki4jAppender">
+ <!--
+ Loki Cloud hosted solution is limiting the batch size to 65536 Bytes, our log lines are exceeding this
+ limit quite often so we are sending them with a granularity of 1 instead of the default 1000.
+ The library does not provide a `batchSize` expressed in Bytes yet, so we cannot set it smarter than that.
+ -->
+ <batchSize>1</batchSize>
+ <batchTimeoutMs>10000</batchTimeoutMs>
+ <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