Skip to content

fix: honor -stderrthreshold when -logtostderr=true#391

Open
pierluigilenoci wants to merge 1 commit intowerf:mainfrom
pierluigilenoci:fix/honor-stderrthreshold
Open

fix: honor -stderrthreshold when -logtostderr=true#391
pierluigilenoci wants to merge 1 commit intowerf:mainfrom
pierluigilenoci:fix/honor-stderrthreshold

Conversation

@pierluigilenoci
Copy link
Copy Markdown

What

Bump klog to v2.140.0 and opt into the fixed behavior so that -stderrthreshold is respected even when -logtostderr=true (the default).

Why

klog v2 defaults -logtostderr to true. When active, the -stderrthreshold flag is silently ignored — all log severities are unconditionally written to stderr. This makes it impossible for log-aggregation systems to filter by severity.

This has been an open issue since 2020: kubernetes/klog#212

The fix was merged in klog v2.140.0 via kubernetes/klog#432 (authored by me) and introduces an opt-in flag legacy_stderr_threshold_behavior. Setting it to false enables the corrected behavior where -stderrthreshold is honored.

What changes

  1. klog bumped from v2.120.1 to v2.140.0
  2. In cmd/kubedog/main.go SilenceKlog(), after klog.InitFlags(fs), legacy_stderr_threshold_behavior=false is set to ensure the existing stderrthreshold setting is properly honored.

References

klog v2 defaults -logtostderr to true, which silently ignores
-stderrthreshold — all severities are unconditionally sent to stderr.

Bump klog to v2.140.0 and opt into the fixed behavior by setting
legacy_stderr_threshold_behavior=false so that -stderrthreshold is
respected. The default is set to INFO (preserving current behavior);
users can now override it on the command line.

Ref: kubernetes/klog#212, kubernetes/klog#432

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
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

Successfully merging this pull request may close these issues.

1 participant