diff --git a/internal/home/config.go b/internal/home/config.go index b2161373ae6..ac42afde92b 100644 --- a/internal/home/config.go +++ b/internal/home/config.go @@ -439,7 +439,7 @@ func readLogSettings() (ls *logSettings) { yamlFile, err := readConfigFile() if err != nil { - return &logSettings{} + return nil } err = yaml.Unmarshal(yamlFile, conf) diff --git a/internal/home/home.go b/internal/home/home.go index a4f5c9e536d..1d28646444e 100644 --- a/internal/home/home.go +++ b/internal/home/home.go @@ -794,22 +794,19 @@ func configureLogger(opts options) (err error) { // getLogSettings returns a log settings object properly initialized from opts. func getLogSettings(opts options) (ls *logSettings) { - ls = readLogSettings() configLogSettings := config.Log + ls = readLogSettings() + if ls == nil { + // Use default log settings. + ls = &configLogSettings + } + // Command-line arguments can override config settings. - if opts.verbose || configLogSettings.Verbose { + if opts.verbose { ls.Verbose = true } - - ls.File = stringutil.Coalesce(opts.logFile, configLogSettings.File, ls.File) - - // Handle default log settings overrides. - ls.Compress = configLogSettings.Compress - ls.LocalTime = configLogSettings.LocalTime - ls.MaxBackups = configLogSettings.MaxBackups - ls.MaxSize = configLogSettings.MaxSize - ls.MaxAge = configLogSettings.MaxAge + ls.File = stringutil.Coalesce(opts.logFile, ls.File) if opts.runningAsService && ls.File == "" && runtime.GOOS == "windows" { // When running as a Windows service, use eventlog by default if