-
Notifications
You must be signed in to change notification settings - Fork 273
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
Add support for JSON-formatted logging #7083
Add support for JSON-formatted logging #7083
Conversation
Hi @zarvd. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
/ok-to-test |
// utilflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the | ||
// normalize func and add the go flag set by hand. | ||
// utilflag.InitFlags() | ||
logs.InitLogs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it impacts existing klog logic when json format is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I have moved the logic from logs.InitLogs() to log.Setup(). It should not impact the default klog logger.
cloud-provider-azure/pkg/log/logger.go
Lines 75 to 77 in bd1057d
log.SetOutput(logs.KlogWriter{}) | |
log.SetFlags(0) | |
klog.StartFlushDaemon(opts.FlushFrequency) |
6bac80a
to
49e8501
Compare
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feiskyer, zarvd The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
49e8501
to
3c07f6e
Compare
/retest |
1 similar comment
/retest |
3c07f6e
to
fc77dff
Compare
/retest |
fc77dff
to
ee08bc6
Compare
ee08bc6
to
c4d1621
Compare
/retest |
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
It adds a CLI flag
--log-format
to cloud-controller-manager, which supports a new logging format JSON. When --log-format=json is set, the loggers of both klog and slog will print log messages as JSON. Structured logging is easier to query and filter.NOTE
klog.V(N)
will be attached to the log key-value with the namev
, as in{"level":"info", "msg":"foo", "v":"5"}
. But logs withlevel=error
always have a verbosity of 0.Sample Output
Which issue(s) this PR fixes:
part of #1575
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: