Kubebuilder: Question: How to use klog as the logging library?

Created on 12 Nov 2020  路  4Comments  路  Source: kubernetes-sigs/kubebuilder

How to use klog library for the controller?
Please share an example.. if it is possible or not.

/triage support

kinsupport

Most helpful comment

I do this by replacing the line ctrl.SetLogger(zap.New(zap.UseDevMode(true))) in main.go with ctrl.SetLogger(klogr.New()); the import is "k8s.io/klog/klogr"

All 4 comments

@alok87: The label(s) triage/support cannot be applied, because the repository doesn't have them

In response to this:

How to use klog library for the controller?
Please share an example.. if it is possible or not.

/triage support

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

I do this by replacing the line ctrl.SetLogger(zap.New(zap.UseDevMode(true))) in main.go with ctrl.SetLogger(klogr.New()); the import is "k8s.io/klog/klogr"

I understand that it is sorted out as described above. So, I am closing this one. However, please feel free to ping us if you think that it should be re-opened.

It works, thanks @justinsb :)

Was this page helpful?
0 / 5 - 0 ratings