diff --git a/pkg/logging/log.go b/pkg/logging/log.go index 3c00f8003a..a501fda99b 100644 --- a/pkg/logging/log.go +++ b/pkg/logging/log.go @@ -43,6 +43,7 @@ func Init(flags *flag.FlagSet) { // Setup configures the logger with the supplied log format. // It returns an error if the JSON logger could not be initialized or passed logFormat is not recognized. +// LogLevel parameter is used to configure zap. func Setup(logFormat string) error { switch logFormat { case TextFormat: @@ -53,9 +54,9 @@ func Setup(logFormat string) error { if err != nil { return err } - klog.SetLogger(zapr.NewLogger(zapLog)) - // in json mode we use FormatKlog format - globalLog = klog.NewKlogr() + globalLog = zapr.NewLogger(zapLog) + // in json mode we configure klog and global logger to use zapr + klog.SetLogger(globalLog.WithName("klog")) default: return errors.New("log format not recognized, pass `text` for text mode or `json` to enable JSON logging") }