matrix-synapse: Add support for structured logging

This commit is contained in:
Jan Tomšič 2023-06-12 15:07:34 +02:00
parent 1c29ec73eb
commit 2cf50ffa28
2 changed files with 22 additions and 3 deletions

View file

@ -9,8 +9,13 @@ data:
log.yaml: |
version: 1
formatters:
{{- if .Values.config.useStructuredLogging }}
structured:
class: synapse.logging.TerseJsonFormatter
{{- else }}
precise:
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s'
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s'
{{- end }}
filters:
context:
(): synapse.util.logcontext.LoggingContextFilter
@ -18,12 +23,15 @@ data:
handlers:
console:
class: logging.StreamHandler
formatter: precise
formatter: {{ if .Values.config.useStructuredLogging }}structured{{ else }}precise{{ end }}
filters: [context]
level: {{ .Values.config.logLevel | default "INFO" }}
loggers:
synapse:
level: {{ .Values.config.logLevel | default "INFO" }}
level: {{ .Values.config.logLevel | default "INFO" }}
{{- with .Values.extraLoggers -}}
{{ . | toYaml | nindent 8 }}
{{- end }}
root:
level: {{ .Values.config.logLevel | default "INFO" }}
handlers: [console]

View file

@ -140,6 +140,11 @@ config:
extraMainListenerTypes: []
# - consent
## Logging
# use TerseJsonFormatter structured logging
# Ref: https://matrix-org.github.io/synapse/latest/structured_logging.html
useStructuredLogging: false
## Specify arbitrary Synapse configuration here;
## Ref: https://github.com/matrix-org/synapse/blob/develop/docs/sample_config.yaml
##
@ -154,6 +159,12 @@ extraConfig: {}
# - syd.example.com
# dynamic_thumbnails: true
## Specify additional loggers configutation here;
## Ref: https://matrix-org.github.io/synapse/latest/structured_logging.html
extraLoggers: {}
# synapse.storage.SQL:
# level: WARNING
## Specify arbitrary - secret - Synapse configuration here;
## These values will be stored in secrets instead of configmaps
## Ref: https://github.com/matrix-org/synapse/blob/develop/docs/sample_config.yaml