Skip to content

Commit

Permalink
Populate default settings for logging.file.* (#17332) (#17370)
Browse files Browse the repository at this point in the history
If the configured environment default to stderr logging, then the
logging.file.* settings are not populated anymore, which requires users
to configure all settings if they don't want to default to stderr. The change sets the
default settings for logging.file.* always.

(cherry picked from commit 0b781b2)

Co-authored-by: Steffen Siering <steffen.siering@elastic.co>
  • Loading branch information
mikemadden42 and Steffen Siering authored Mar 31, 2020
1 parent 43c74cd commit 7ad184e
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions libbeat/logp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type FileConfig struct {
RedirectStderr bool `config:"redirect_stderr"`
}

const defaultLevel = InfoLevel

// DefaultConfig returns the default config options for a given environment the
// Beat is supposed to be run within.
func DefaultConfig(environment Environment) Config {
Expand All @@ -70,23 +72,28 @@ func DefaultConfig(environment Environment) Config {

func defaultToStderrConfig() Config {
return Config{
Level: InfoLevel,
Level: defaultLevel,
ToStderr: true,
Files: defaultFileConfig(),
addCaller: true,
}
}

func defaultToFileConfig() Config {
return Config{
Level: InfoLevel,
ToFiles: true,
Files: FileConfig{
MaxSize: 10 * 1024 * 1024,
MaxBackups: 7,
Permissions: 0600,
Interval: 0,
RotateOnStartup: true,
},
Level: defaultLevel,
ToFiles: true,
Files: defaultFileConfig(),
addCaller: true,
}
}

func defaultFileConfig() FileConfig {
return FileConfig{
MaxSize: 10 * 1024 * 1024,
MaxBackups: 7,
Permissions: 0600,
Interval: 0,
RotateOnStartup: true,
}
}

0 comments on commit 7ad184e

Please sign in to comment.