Skip to content

Commit

Permalink
[Ingest Manager] Move logging defaults to agent (elastic#24535)
Browse files Browse the repository at this point in the history
[Ingest Manager] Move logging defaults to agent (elastic#24535)
  • Loading branch information
michalpristas authored Mar 15, 2021
1 parent 4f72a77 commit 6dbce20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions libbeat/logp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ const defaultLevel = InfoLevel
// Beat is supposed to be run within.
func DefaultConfig(environment Environment) Config {
return Config{
Level: defaultLevel,
ToFiles: true,
Level: defaultLevel,
Files: FileConfig{
MaxSize: 10 * 1024 * 1024,
MaxBackups: 7,
Expand Down
9 changes: 6 additions & 3 deletions x-pack/elastic-agent/pkg/core/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@ func new(name string, cfg *Config) (*Logger, error) {
return nil, err
}

var outputs []zapcore.Core
if cfg.ToFiles {
internal, err := makeInternalFileOutput(cfg)
if err != nil {
return nil, err
}

if err := configure.LoggingWithOutputs("", commonCfg, internal); err != nil {
return nil, fmt.Errorf("error initializing logging: %v", err)
}
outputs = append(outputs, internal)
}

if err := configure.LoggingWithOutputs("", commonCfg, outputs...); err != nil {
return nil, fmt.Errorf("error initializing logging: %v", err)
}
return logp.NewLogger(name), nil
}

Expand All @@ -92,6 +94,7 @@ func DefaultLoggingConfig() *Config {
cfg := logp.DefaultConfig(logp.DefaultEnvironment)
cfg.Beat = agentName
cfg.Level = logp.InfoLevel
cfg.ToFiles = true
cfg.Files.Path = paths.Logs()
cfg.Files.Name = fmt.Sprintf("%s.log", agentName)

Expand Down

0 comments on commit 6dbce20

Please sign in to comment.