diff --git a/cmd/buildkitd/config/config.go b/cmd/buildkitd/config/config.go index 65447eda0cc4..4709c555bb2c 100644 --- a/cmd/buildkitd/config/config.go +++ b/cmd/buildkitd/config/config.go @@ -63,6 +63,7 @@ type SystemConfig struct { type LogConfig struct { Format string `toml:"format"` + Level string `toml:"level"` } type GRPCConfig struct { diff --git a/cmd/buildkitd/main.go b/cmd/buildkitd/main.go index 808feaa00aaa..bc6ab4c79ddd 100644 --- a/cmd/buildkitd/main.go +++ b/cmd/buildkitd/main.go @@ -186,6 +186,12 @@ func main() { Usage: "log formatter: json or text", Value: "text", }, + cli.StringFlag{ + Name: "log-level", + Usage: "set the log level", + Value: "info", + EnvVar: "BUILDKITD_LOG_LEVEL", + }, cli.StringFlag{ Name: "group", Usage: groupUsageStr, @@ -273,6 +279,14 @@ func main() { logrus.SetLevel(logrus.TraceLevel) } + if cfg.Log.Level != "" { + level, err := logrus.ParseLevel(cfg.Log.Level) + if err != nil { + return errors.Wrap(err, "unsupported log level") + } + logrus.SetLevel(level) + } + if sc := cfg.System; sc != nil { if v := sc.PlatformsCacheMaxAge; v != nil { archutil.CacheMaxAge = v.Duration @@ -598,6 +612,9 @@ func applyMainFlags(c *cli.Context, cfg *config.Config) error { if c.IsSet("log-format") { cfg.Log.Format = c.String("log-format") } + if c.IsSet("log-level") { + cfg.Log.Level = c.String("log-level") + } if c.IsSet("addr") || len(cfg.GRPC.Address) == 0 { cfg.GRPC.Address = c.StringSlice("addr") }