diff --git a/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go b/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go index 00f804ad31..1252609832 100644 --- a/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go +++ b/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go @@ -262,7 +262,7 @@ func runAgent(ctx context.Context, writer := logger.NewLogWriter(logConfig) - log.Printf("I! Starting AmazonCloudWatchAgent %s\n", version.Full()) + log.Printf("I! Starting AmazonCloudWatchAgent %s with log file %s with log target %s\n", version.Full(), ag.Config.Agent.Logfile, ag.Config.Agent.LogTarget) // Need to set SDK log level before plugins get loaded. // Some aws.Config objects get created early and live forever which means // we cannot change the sdk log level without restarting the Agent. diff --git a/translator/translate/otel/translate_otel.go b/translator/translate/otel/translate_otel.go index 9e53cf1689..ea2973fb7f 100644 --- a/translator/translate/otel/translate_otel.go +++ b/translator/translate/otel/translate_otel.go @@ -18,7 +18,7 @@ import ( "go.uber.org/zap/zapcore" receiverAdapter "github.com/aws/amazon-cloudwatch-agent/receiver/adapter" - "github.com/aws/amazon-cloudwatch-agent/translator/translate/agent" + "github.com/aws/amazon-cloudwatch-agent/translator/context" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/pipeline" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/pipeline/appsignals" @@ -104,16 +104,6 @@ func Translate(jsonConfig interface{}, os string) (*otelcol.Config, error) { return cfg, nil } -// parseAgentLogFile returns the log file path form the JSON config, or the -// default value. -func parseAgentLogFile(conf *confmap.Conf) string { - v, ok := common.GetString(conf, common.ConfigKey("agent", "logfile")) - if !ok { - return agent.GetDefaultValue() - } - return v -} - // parseAgentLogLevel returns the logging level from the JSON config, or the // default value. func parseAgentLogLevel(conf *confmap.Conf) zapcore.Level { @@ -133,7 +123,7 @@ func parseAgentLogLevel(conf *confmap.Conf) zapcore.Level { // logging configuration that should go in the YAML. func getLoggingConfig(conf *confmap.Conf) telemetry.LogsConfig { var outputPaths []string - filename := parseAgentLogFile(conf) + filename := context.CurrentContext().GetAgentLogFile() // A slice with an empty string causes OTEL issues, so avoid it. if filename != "" { outputPaths = []string{filename}