-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add a way to log all/some configuration at startup #8218
Comments
There is a ticket asking to support sensitive data in MP Config: eclipse/microprofile-config#451 |
Smallrye Config 1.8 already supports this. Once we merge #9184 we can add the feature. |
I think we should close this as the we now have support for this in the DevUI. |
@geoand coincidentally, yesterday I was in the need to see the effective config in non dev mode. Having some support for this would come in handy. |
We'd need to be careful to not introduce a security issue if we're going to support that, for example, you'd need to be authenticated if your application is public. |
Valid point! But I do think that this would not be something you enable all the time. Anyway, I just wanted to point out that this enhancement request still relevant, IMO. |
For the record, I was referring to be authenticated if we're introducing a web page showing configuration options. Showing the config in the logs during the startup (except with sensitive data) may be a nice thing to have though |
BTW, this is already supported: The interceptor is not registered by default, but if you add it you will get the logging. |
@radcortez that's awesome! Is this mentioned in the Quarkus docs or in a guide somewhere we can point users to? |
No, but I can add it. |
@famod do you want to try the interceptor approach? Just register the If this works for you, I can just add a configuration to auto-register the interceptor. |
@radcortez I'll try to find some time on sunday or so. |
@radcortez well, the interceptor seems to kick in but I don't see anything on the console. |
Could it be that I cannot set the level of |
The logging name is |
Ok thanks, I'm now seeing (in getting-started quickstart):
This is very useful! I'm just wondering whether a more "compact" output could be added? E.g. in properties format? Or even YAML (additionally)? |
Some emoticons would be nice too, like ❌ for missing properties and ✔️ for existing ones |
But IMHO showing only what's set should be enough, given the amount of properties |
This can be really verbose, especially because Quarkus deals with a huge number of configurations. Also, because we start two instances of Regarding a properties format or yaml, I think that is a different use case. What we have here is a log entry for each lookup to a certain configuration name. I think this format makes sense. I'm guessing that you prefer to have something that just outputs the current state of the configuration? |
Primarily, yes. But I also do see the benefit of getting more details of the "why" in some cases. |
@radcortez are there any improvements on this since 2021? I cannot see any. |
If you add a |
I am using default String toString() {
return "thestring";
} I get this |
You can. Just add the @ConfigMapping(prefix = "server")
interface ToStringMapping {
String host();
int port();
List<Alias> aliases();
String toString();
interface Alias {
String name();
String toString();
}
} And if you try it: SmallRyeConfig config = new SmallRyeConfigBuilder()
.withMapping(ToStringMapping.class)
.withSources(config(
"server.host", "localhost",
"server.port", "8080",
"server.aliases[0].name", "prod-1",
"server.aliases[1].name", "prod-2"))
.withConverter(Version.class, 100, new VersionConverter())
.build();
ToStringMapping mapping = config.getConfigMapping(ToStringMapping.class);
System.out.println(mapping.toString()); You get:
|
@radcortez it worked thanks! Any chance it's documented somewhere and I missed it? I think it's something important to highlight. |
Ah ... the usual problem between doc in Quarkus and not duplicating what is already in the Smallrye doc :-( |
The links in this discussion are so valuable but imho hard to find. The config interceptor doc is at https://smallrye.io/smallrye-config/Main/extensions/interceptors/ now, the mappings at https://smallrye.io/smallrye-config/Main/config/mappings/ . |
In the meantime, we added a configuration to log the values, and it is part of the Quarkus Config documentation: https://quarkus.io/guides/config-reference#configuration-reference How can we make this more visible? |
Description
It would be great to have a way to log all/some configuration at startup.
In my mind:
quarkus.log-config-at-startup=true
@ConfigProperties(..., enableLog="true")
,@ConfigProperty(..., enableLog="true")
As discussed with @dmlloyd and @geoand there already are some efforts in that direction:
We also discussed some problems to be figured out:
The text was updated successfully, but these errors were encountered: