Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zapr log levels don't align with glog/klog recommendations #3081

Open
alvaroaleman opened this issue Jan 20, 2025 · 1 comment
Open

Zapr log levels don't align with glog/klog recommendations #3081

alvaroaleman opened this issue Jan 20, 2025 · 1 comment

Comments

@alvaroaleman
Copy link
Member

The named debug log level of zap corresponds to the numeric value -1, which then gets inverted by zapr and thus corresponds toV(1). At the same time, the Kubernetes logging guidelines assume V(4) to be debug level and V(1) A reasonable default log level if you don't want verbosity: https://github.com/kubernetes/community/blob/905825353d20c57817806dd5aab242ea6c703024/contributors/devel/sig-instrumentation/logging.md#what-method-to-use

So the mapping between the two seems off, furthermore most users of zap are likely to not be aware that the log level is an int8 under the hood and can have values outside of the defined named set. We should find a way so that the named debug in zap corresponds to something resembling a debug log level in the glog/klog/logr universe.

@sbueringer
Copy link
Member

sbueringer commented Jan 20, 2025

Just want to mention that component-base uses zap for JSON logging under the hood (while they use klog for text). I didn't look up the details, but sounds like they are using zap in a way that the log levels are treated the same way between zap & klog.

(not saying that's the right "solution", just a data point)

component-base JSON zap implementation can be found here: https://github.com/kubernetes/component-base/blob/master/logs/json/json.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants