From e97bfa88e06742d235f2984e9e4f95633d8cedc6 Mon Sep 17 00:00:00 2001 From: Arjun Raja Yogidas Date: Wed, 13 Nov 2024 02:39:51 +0000 Subject: [PATCH] fix: default json-file log size to 100MB Signed-off-by: Arjun Raja Yogidas --- pkg/logging/json_logger.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/logging/json_logger.go b/pkg/logging/json_logger.go index 5c38bdd1492..16a12ef056c 100644 --- a/pkg/logging/json_logger.go +++ b/pkg/logging/json_logger.go @@ -88,10 +88,11 @@ func (jsonLogger *JSONLogger) PreProcess(dataStore string, config *logging.Confi l := &logrotate.Logger{ Filename: jsonFilePath, } - //maxSize Defaults to unlimited. - var capVal int64 - capVal = -1 + // MaxBytes is the maximum size in bytes of the log file before it gets + // rotated. If not set, it defaults to 100 MiB. + // see: https://github.com/fahedouch/go-logrotate/blob/main/logrotate.go#L500 if capacity, ok := jsonLogger.Opts[MaxSize]; ok { + var capVal int64 var err error capVal, err = units.FromHumanSize(capacity) if err != nil { @@ -100,8 +101,8 @@ func (jsonLogger *JSONLogger) PreProcess(dataStore string, config *logging.Confi if capVal <= 0 { return fmt.Errorf("max-size must be a positive number") } + l.MaxBytes = capVal } - l.MaxBytes = capVal maxFile := 1 if maxFileString, ok := jsonLogger.Opts[MaxFile]; ok { var err error