Skip to content

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

Open

Description

@alvaroaleman

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.

Activity

  1. sbueringer commented on Jan 20, 2025

    @sbueringer
    Member

    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

  2. k8s-triage-robot commented on Apr 20, 2025

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  3. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Apr 20, 2025
  4. sbueringer commented on May 8, 2025

    @sbueringer
    Member

    /remove-lifecycle stale
    /lifecycle frozen

  5. added
    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions