Skip to content

Commit 370b691

Browse files
authored
Merge pull request containerd#3670 from coderbirju/update-json-logger
fix: default json-file log size to 100MB
2 parents 1cfbf4f + 1fdb4b0 commit 370b691

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/logging/json_logger.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ func (jsonLogger *JSONLogger) PreProcess(dataStore string, config *logging.Confi
8888
l := &logrotate.Logger{
8989
Filename: jsonFilePath,
9090
}
91-
//maxSize Defaults to unlimited.
92-
var capVal int64
93-
capVal = -1
91+
// MaxBytes is the maximum size in bytes of the log file before it gets
92+
// rotated. If not set, it defaults to 100 MiB.
93+
// see: https://github.com/fahedouch/go-logrotate/blob/6a8beddaea39b2b9c77109d7fa2fe92053c063e5/logrotate.go#L500
9494
if capacity, ok := jsonLogger.Opts[MaxSize]; ok {
95+
var capVal int64
9596
var err error
9697
capVal, err = units.FromHumanSize(capacity)
9798
if err != nil {
@@ -100,8 +101,8 @@ func (jsonLogger *JSONLogger) PreProcess(dataStore string, config *logging.Confi
100101
if capVal <= 0 {
101102
return fmt.Errorf("max-size must be a positive number")
102103
}
104+
l.MaxBytes = capVal
103105
}
104-
l.MaxBytes = capVal
105106
maxFile := 1
106107
if maxFileString, ok := jsonLogger.Opts[MaxFile]; ok {
107108
var err error

0 commit comments

Comments
 (0)