diff --git a/go.mod b/go.mod index a4ec0cf3357..be9abe648b8 100644 --- a/go.mod +++ b/go.mod @@ -318,4 +318,4 @@ replace ( // Exclude this version because the version has an invalid checksum. exclude github.com/docker/distribution v2.8.0+incompatible -replace github.com/elastic/elastic-agent-libs => github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125141844-ffbc66f6350b +replace github.com/elastic/elastic-agent-libs => github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125162154-3b1dfe492873 diff --git a/go.sum b/go.sum index b9c9e3b135c..0542c1b9692 100644 --- a/go.sum +++ b/go.sum @@ -519,8 +519,8 @@ github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:W github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/aws/aws-sdk-go v1.43.16/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= -github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125141844-ffbc66f6350b h1:GkQYbSAj4LRD/kcMYG89MN3mLTiT5M5/hFKgvSG0DwA= -github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125141844-ffbc66f6350b/go.mod h1:pGMj5myawdqu+xE+WKvM5FQzKQ/MonikkWOzoFTJxaU= +github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125162154-3b1dfe492873 h1:SaT/SfyaB6k77dHDUe9489z6Eu8FAqnbMmlUtWQT9sw= +github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125162154-3b1dfe492873/go.mod h1:pGMj5myawdqu+xE+WKvM5FQzKQ/MonikkWOzoFTJxaU= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= diff --git a/internal/pkg/agent/configuration/settings.go b/internal/pkg/agent/configuration/settings.go index fe9b46ed400..5878d760aa5 100644 --- a/internal/pkg/agent/configuration/settings.go +++ b/internal/pkg/agent/configuration/settings.go @@ -20,7 +20,7 @@ type SettingsConfig struct { GRPC *GRPCConfig `yaml:"grpc" config:"grpc" json:"grpc"` MonitoringConfig *monitoringCfg.MonitoringConfig `yaml:"monitoring" config:"monitoring" json:"monitoring"` LoggingConfig *logger.Config `yaml:"logging,omitempty" config:"logging,omitempty" json:"logging,omitempty"` - SensitiveLoggingConfig *logger.Config `yaml:"logging.sensitive,omitempty" config:"logging.sensitive,omitempty" json:"logging.sensitive,omitempty"` + SensitiveLoggingConfig *logger.Config `config:"-" yaml:"-" json:"-"` Upgrade *UpgradeConfig `yaml:"upgrade" config:"upgrade" json:"upgrade"` // standalone config diff --git a/pkg/component/runtime/command.go b/pkg/component/runtime/command.go index 4db26b02393..40d7aac7b10 100644 --- a/pkg/component/runtime/command.go +++ b/pkg/component/runtime/command.go @@ -554,7 +554,6 @@ func createLogWriter(comp component.Component, baseLog *logger.Logger, cmdSpec * "source": comp.ID, }, ) - return newLogWriter(newLogger.Core(), cmdSpec.Log, ll, unitLevels, src) } diff --git a/pkg/core/logger/logger.go b/pkg/core/logger/logger.go index 56f0de68f73..e5c055afa2c 100644 --- a/pkg/core/logger/logger.go +++ b/pkg/core/logger/logger.go @@ -56,7 +56,10 @@ func NewWithLogpLevel(name string, level logp.Level, logInternal bool) (*Logger, defaultCfg := DefaultLoggingConfig() defaultCfg.Level = level - return new(name, defaultCfg, nil, logInternal) + sensitiveConfig := DefaultSensitiveLoggingConfig() + sensitiveConfig.Level = level + + return new(name, defaultCfg, sensitiveConfig, logInternal) } // NewFromConfig takes the user configuration and generate the right logger. @@ -82,7 +85,7 @@ func AddCallerSkip(l *Logger, skip int) *Logger { return l.WithOptions(zap.AddCallerSkip(skip)) } -// New creates a new logger from the provided configurations. +// new creates a new logger from the provided configurations. // // If `sensitiveLoggerCfg` is not nil, a core is created from it and added to // to the logger. If `logInternal` is true, a core logging to @@ -173,7 +176,8 @@ func DefaultSensitiveLoggingConfig() *Config { cfg.Files.MaxSize = 5 * 1024 * 1024 cfg.Files.MaxBackups = 2 cfg.Files.Permissions = 0600 // default user only - root, _ := utils.HasRoot() // error ignored + cfg.Files.RedirectStderr = false + root, _ := utils.HasRoot() // error ignored if !root { // when not running as root, the default changes to include the group cfg.Files.Permissions = 0660