[k8s]组件日志级别说明

本文详细介绍了Kubernetes中kubectl命令和其他组件的日志记录级别设置,包括从一般性的信息到详细的调试信息的不同等级,并提供了各个级别的适用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

kubectl 执行命令时候 --v 调试,
也可以用作其他组件的 --v配置

参考:
https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/

--v=0   Generally useful for this to ALWAYS be visible to an operator.
--v=1   A reasonable default log level if you don’t want verbosity.
--v=2   Useful steady state information about the service and important log messages that may correlate to significant changes in the system. This is the recommended default log level for most systems.
--v=3   Extended information about changes.
--v=4   Debug level verbosity.
--v=6   Display requested resources.
--v=7   Display HTTP request headers.
--v=8   Display HTTP request contents

参考: https://github.com/kubernetes/community/blob/master/contributors/devel/logging.md

The following conventions for the glog levels to use. glog is globally preferred to log for better runtime control.

glog.Errorf() - Always an error

glog.Warningf() - Something unexpected, but probably not an error

glog.Infof() has multiple levels:

glog.V(0) - Generally useful for this to ALWAYS be visible to an operator
Programmer errors
Logging extra info about a panic
CLI argument handling
glog.V(1) - A reasonable default log level if you don't want verbosity.
Information about config (listening on X, watching Y)
Errors that repeat frequently that relate to conditions that can be corrected (pod detected as unhealthy)
glog.V(2) - Useful steady state information about the service and important log messages that may correlate to significant changes in the system. This is the recommended default log level for most systems.
Logging HTTP requests and their exit code
System state changing (killing pod)
Controller state change events (starting pods)
Scheduler log messages
glog.V(3) - Extended information about changes
More info about system state changes
glog.V(4) - Debug level verbosity (for now)
Logging in particularly thorny parts of code where you may want to come back later and check it
As per the comments, the practical default level is V(2). Developers and QE environments may wish to run at V(3) or V(4). If you wish to change the log level, you can pass in -v=X where X is the desired maximum level to log.

参考: https://rootsongjc.gitbooks.io/kubernetes-handbook/content/guide/kubectl-cheatsheet.html
https://kubernetes.io/docs/user-guide/kubectl-overview/

9e792b8fgy1flt4q5vnj2j20m00kegme.jpg

转载于:https://www.cnblogs.com/iiiiher/p/7879817.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值