Skip to content

Setting log level via environment variables does not work #540

Description

@shapirus

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions