diff --git a/graph/pkg/command/root.go b/graph/pkg/command/root.go index aae6a90556..ec758502c3 100644 --- a/graph/pkg/command/root.go +++ b/graph/pkg/command/root.go @@ -65,6 +65,7 @@ func NewLogger(cfg *config.Config) log.Logger { log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), log.Color(cfg.Log.Color), + log.File(cfg.Log.File), ) } @@ -123,6 +124,7 @@ func NewSutureService(cfg *ociscfg.Config) suture.Service { if cfg.Mode == 0 { cfg.Graph.Supervised = true } + cfg.Graph.Log.File = cfg.Log.File return SutureService{ cfg: cfg.Graph, } diff --git a/graph/pkg/config/config.go b/graph/pkg/config/config.go index 580652a899..433e9e72ff 100644 --- a/graph/pkg/config/config.go +++ b/graph/pkg/config/config.go @@ -7,6 +7,7 @@ type Log struct { Level string Pretty bool Color bool + File string } // Debug defines the available debug configuration. diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index bd9efe93ce..c4734797a2 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -53,6 +53,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { // ServerWithConfig applies cfg to the root flagset func ServerWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "log-file", + Usage: "Enable log to file", + EnvVars: []string{"GRAPH_LOG_FILE", "OCIS_LOG_FILE"}, + Destination: &cfg.Log.File, + }, &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces",