Skip to content
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

Logging configuration ignores environment variables #1887

Closed
hwellmann opened this issue Apr 5, 2019 · 4 comments
Closed

Logging configuration ignores environment variables #1887

hwellmann opened this issue Apr 5, 2019 · 4 comments
Labels
area/config pinned Issue will never be marked as stale
Milestone

Comments

@hwellmann
Copy link

It seems that logging configuration only respects system properties but ignores environment variables.

Example:

This disables color output:

java  -Dquarkus.log.console.color=false -jar application-configuration-1.0-SNAPSHOT-runner.jar

This should do the same, but has no effect:

QUARKUS_LOG_CONSOLE_COLOR=false java -jar application-configuration-1.0-SNAPSHOT-runner.jar
@dmlloyd
Copy link
Member

dmlloyd commented Apr 8, 2019

This is a little bit of a complex issue. We parse the configuration by iterating all the available configuration keys, so we can detect invalid items and also use free-form object mapping. The mapping of configuration key to environment variable name is one-way: that is, you can only find the environment variable from the configuration key, not the other way around. Putting these two things together means that configuration properties which are given only by environment variable will not be seen.

There are two workarounds. One is to supply just an empty value for the key in your application.properties, which will cause the key to be found and the environment variable to be read (since it would be a higher priority than the file). The other would be to give a value like this for the key:

quarkus.log.console.color=${COLOR_LOGGING:true}

And then just pass in a value for COLOR_LOGGING.

I know these workarounds are not ideal, but I'm still working on a viable solution.

@fabricepipart
Copy link
Contributor

I ran into the same problem today and I had to refer to this issue to understand how to use a Kubernetes secret to define the datasource password (quarkus.datasource.password property).

According to me the current behaviour is fine. You define the property in application.properties but you can override it via environment variables. I even prefer that, this way all properties are declared in the same place.
I also did not realise that you could use bash-like syntax to refer to environment variables. Would you agree that I specify all those in the user guide ?

@dmlloyd
Copy link
Member

dmlloyd commented Aug 26, 2019

I also did not realise that you could use bash-like syntax to refer to environment variables. Would you agree that I specify all those in the user guide ?

This is not strictly accurate; it's clearer to say that you can specify configuration values in your environment (see https://github.com/eclipse/microprofile-config/blob/master/spec/src/main/asciidoc/configsources.asciidoc#default-configsources for more info), and we also support Apache-style variable expansion (with a syntax of ${config.prop.name} or ${config.prop.name:defaultValue} which is also proposed for a future MicroProfile Configuration release. The combination of the two looks somewhat like Bash- or Make-style variables but it's not exactly the same thing.

@stale
Copy link

stale bot commented Nov 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you!
We are doing this automatically to ensure out-of-date issues does not stay around indefinitely.
If you believe this issue is still relevant please put a comment on it on why and if it truly needs to stay request or add 'pinned' label.

@stale stale bot added the stale label Nov 13, 2019
@dmlloyd dmlloyd added pinned Issue will never be marked as stale and removed stale labels Nov 13, 2019
@gsmet gsmet added this to the 1.1.0 milestone Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config pinned Issue will never be marked as stale
Projects
None yet
Development

No branches or pull requests

4 participants