vouch-proxy
vouch-proxy copied to clipboard
Setting log level via environment variables does not work
No matter what value VOUCH_LOGLEVEL
environment variable is set to, effective value always ends up being info
.
Setting it via the config file, on the other hand, does work.
I believe it happens because of the following code in pkg/cfg/logging.go
, func (logging) configure() {
:
// then we weren't configured via command line, check the config file
if !viper.IsSet(Branding.LCName + ".logLevel") {
// then we weren't configured via the config file, set the default
Cfg.LogLevel = fmt.Sprintf("%s", Logging.DefaultLogLevel)
}
if Cfg.LogLevel != Logging.AtomicLogLevel.Level().String() {
// log.Errorf("Logging.configure() Logging.LogLevel %s Cfg.LogLevel %s", Logging.LogLeveLogging.String(), Cfg.LogLevel)
Logging.setLogLevelString(Cfg.LogLevel)
}
As we can see, Cfg.LogLevel
is forced to the default value, unless it is set in the config file, and, if I'm not mistaken, the environment variable never has a chance to take effect.
This was tested with quay.io/vouch/vouch-proxy:0.39
. To be honest, I didn't try to set any values other than debug
, but I don't think it would've changed anything.
yep, looks like a bug!
Thanks much