diff --git a/go.mod b/go.mod index 5a1e5fdc6..b16f80724 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,7 @@ require ( k8s.io/apimachinery v0.30.0 k8s.io/cli-runtime v0.30.0 k8s.io/client-go v0.30.0 + k8s.io/klog/v2 v2.120.1 k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 sigs.k8s.io/controller-runtime v0.18.2 sigs.k8s.io/yaml v1.4.0 @@ -166,7 +167,6 @@ require ( k8s.io/apiextensions-apiserver v0.30.0 // indirect k8s.io/apiserver v0.30.0 // indirect k8s.io/component-base v0.30.0 // indirect - k8s.io/klog/v2 v2.120.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect k8s.io/kubectl v0.30.0 // indirect moul.io/http2curl/v2 v2.3.0 // indirect diff --git a/main.go b/main.go index d9435e175..8bd9f29a4 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ import ( "k8s.io/client-go/kubernetes" clientgoscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + "k8s.io/klog/v2" elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1" elbv2controller "sigs.k8s.io/aws-load-balancer-controller/controllers/elbv2" "sigs.k8s.io/aws-load-balancer-controller/controllers/ingress" @@ -75,7 +76,9 @@ func main() { infoLogger.Error(err, "unable to load controller config") os.Exit(1) } - ctrl.SetLogger(getLoggerWithLogLevel(controllerCFG.LogLevel)) + appLogger := getLoggerWithLogLevel(controllerCFG.LogLevel) + ctrl.SetLogger(appLogger) + klog.SetLoggerWithOptions(appLogger, klog.ContextualLogger(true)) cloud, err := aws.NewCloud(controllerCFG.AWSConfig, metrics.Registry, ctrl.Log) if err != nil {