Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest Manager] Logging to file disabled on enroll #24466

Merged
merged 3 commits into from
Mar 10, 2021
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: 2 additions & 1 deletion libbeat/logp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const defaultLevel = InfoLevel
// Beat is supposed to be run within.
func DefaultConfig(environment Environment) Config {
return Config{
Level: defaultLevel,
Level: defaultLevel,
ToFiles: true,
Files: FileConfig{
MaxSize: 10 * 1024 * 1024,
MaxBackups: 7,
Expand Down
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- Fix failing installation on windows 7 {pull}[24387]24387
- Fix capabilities resolution in inspect command {pull}[24346]24346
- Fix windows installer during enroll {pull}[24343]24343
- Logging to file disabled on enroll {issue}[24173]24173

==== New features

Expand Down
5 changes: 5 additions & 0 deletions x-pack/elastic-agent/pkg/agent/cmd/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ func enroll(streams *cli.IOStreams, cmd *cobra.Command, flags *globalFlags, args
}
}

// enroll is invoked either manually or from install with redirected IO
// no need to log to file
cfg.Settings.LoggingConfig.ToFiles = false
cfg.Settings.LoggingConfig.ToStderr = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Does this need to be set on any other subcommands?

Copy link
Contributor Author

@michalpristas michalpristas Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we use just install, uninstall, upgrade and reexec (on win) where we don't use logger
enroll where we use it
watcher has its own configuration
and run which is a normal state

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response.


logger, err := logger.NewFromConfig("", cfg.Settings.LoggingConfig)
if err != nil {
return err
Expand Down
17 changes: 11 additions & 6 deletions x-pack/elastic-agent/pkg/core/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ func new(name string, cfg *Config) (*Logger, error) {
if err != nil {
return nil, err
}
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)

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)
}
}

return logp.NewLogger(name), nil
}

Expand Down