From c6177c4d18c5394d1055fb2c34a295eb8c5fe289 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 29 Jul 2023 17:58:09 +0200 Subject: [PATCH] Add support for JSON logging --- cmd/app/main.go | 4 ++++ internal/services/configuration.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/cmd/app/main.go b/cmd/app/main.go index a41ac82..6cfe281 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -72,6 +72,10 @@ func main() { logger.SetLevel(logLevel) } + if config.Bool("log.json") { + logger.SetFormatter(&log.JSONFormatter{}) + } + bundle, catalog := services.InitI18n(logger, config.Strings("i18n.languages")) services.AddMessages(catalog) diff --git a/internal/services/configuration.go b/internal/services/configuration.go index 2c736f8..5496118 100644 --- a/internal/services/configuration.go +++ b/internal/services/configuration.go @@ -43,6 +43,8 @@ var DefaultConfiguration = map[string]interface{}{ "oidc.server": "https://auth.cacert.localhost:4444/", "session.path": "sessions/app", "i18n.languages": []string{"en", "de"}, + "log.level": "info", + "log.json": true, } func ConfigureApplication(