From 5793ff636684a0fd1f53e202aea2e7e4dc07de1e Mon Sep 17 00:00:00 2001 From: Sven Rebhan <36194019+srebhan@users.noreply.github.com> Date: Fri, 1 Nov 2024 22:20:42 +0100 Subject: [PATCH] fix(logger): Avoid setting the log-format default too early (#16108) --- config/config.go | 1 - logger/logger.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 4f6da0c9f..ac242e532 100644 --- a/config/config.go +++ b/config/config.go @@ -123,7 +123,6 @@ func NewConfig() *Config { Interval: Duration(10 * time.Second), RoundInterval: true, FlushInterval: Duration(10 * time.Second), - LogFormat: "text", LogfileRotationMaxArchives: 5, }, diff --git a/logger/logger.go b/logger/logger.go index 535f4150b..c344838c0 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -227,6 +227,10 @@ func SetupLogging(cfg *Config) error { return fmt.Errorf("invalid deprecated 'logtarget' setting %q", cfg.LogTarget) } + if cfg.LogFormat == "" { + cfg.LogFormat = "text" + } + if cfg.Debug { cfg.logLevel = telegraf.Debug }