I am using the kubernetes sample controller and I want to increase the log verbosity
On starting up the controller I tried ./sample-controller -kubeconfig=kubeconfig.yaml -v=8
Does klog require a flag to be passed in on the flag.Parse() step or can I set some env variable to increase log level?
from their source code:
flagset.Var(&logging.verbosity, "v", "number for the log level verbosity")
.
.
.
// get returns the value of the Level.
func (l *Level) get() Level {
return Level(atomic.LoadInt32((*int32)(l)))
}
so the answer is yes, all you need to do is to use the v flag.
to know which number is which, read this article :
With VLOG, the lower the verbose level, the more likely messages are to be logged. For example, if --v==1, VLOG(1) will log, but VLOG(2) will not log. This is opposite of the severity level, where INFO is 0, and ERROR is 2. --minloglevel of 1 will log WARNING and above. Though you can specify any integers for both VLOG macro and --v flag, the common values for them are small positive integers. For example, if you write VLOG(0), you should specify --v=-1 or lower to silence it. This is less useful since we may not want verbose logs by default in most cases. The VLOG macros always log at the INFO log level (when they log at all).