Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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