diff --git a/CHANGELOG.md b/CHANGELOG.md index 6640c2180..3125f82d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ - Allow the collector run in the non-Kubernetes environment by setting the option `enable` `false` under the `k8smetadataprocessor` section. ([#285](https://github.com/CloudDectective-Harmonycloud/kindling/pull/285)) - Add a new environment variable: IS_PRINT_EVENT. When the value is true, sinsp events can be printed to the stdout. ([#283](https://github.com/CloudDectective-Harmonycloud/kindling/pull/283)) - Declare the 9500 port in the agent's deployment file ([#282](https://github.com/CloudDectective-Harmonycloud/kindling/pull/282)) -### Bug fixes +### Bug fixes +- Avoid printing logs to console when both `observability.logger.file_level` and `observability.logger.console_level` are set to none([#316](https://github.com/CloudDectective-Harmonycloud/kindling/pull/316)) - Fix the userAttributes array out of range error caused by userAttNumber exceeding 8 - Fix the bug where no HTTP headers were got. ([#301](https://github.com/CloudDectective-Harmonycloud/kindling/pull/301)) - Fix the bug that need_trace_as_span options cannot take effect ([#292](https://github.com/CloudDectective-Harmonycloud/kindling/pull/292)) diff --git a/collector/pkg/observability/logger/logger.go b/collector/pkg/observability/logger/logger.go index bf1263888..a6ad192fe 100644 --- a/collector/pkg/observability/logger/logger.go +++ b/collector/pkg/observability/logger/logger.go @@ -53,8 +53,8 @@ func InitLogger(config Config) *zap.Logger { logger.Sugar().Infof("Log Initialize Success! ConsoleLevel: %s,FileRotationLevel: %s", consoleLogLevel.String(), "none") return logger } else { - // By default, the console at the Info level is used to record logs - consoleLogLevel = zapcore.InfoLevel + // Both none, only record the panic log to console + consoleLogLevel = zapcore.DPanicLevel logger := CreateConsoleLogger() logger.Sugar().Infof("Log Initialize Success! ConsoleLevel: %s,FileRotationLevel: %s", consoleLogLevel.String(), "none") return logger diff --git a/collector/pkg/observability/logger/logger_test.go b/collector/pkg/observability/logger/logger_test.go deleted file mode 100644 index 3b6fafabc..000000000 --- a/collector/pkg/observability/logger/logger_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package logger - -import ( - "testing" - - "go.uber.org/zap" - "gopkg.in/natefinch/lumberjack.v2" -) - -func Test_newLogger(t *testing.T) { - config := &lumberjack.Logger{ - Filename: "tmp.log", - MaxSize: 500, // megabytes - MaxBackups: 3, - MaxAge: 28, - LocalTime: true, - Compress: false, - } - logger := CreateCombineLogger(config) - logger.Info("This is a Info test", zap.String("param1", "value1")) - logger.Debug("This is a Info test", zap.String("param1", "value1")) -}