Skip to content

Commit

Permalink
Populate default settings for logging.file.* (elastic#17332)
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)
  • Loading branch information
Steffen Siering authored and mikemadden42 committed Mar 31, 2020
1 parent 99b4bd8 commit c70a0eb
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 c70a0eb

Please sign in to comment.