I'm use myConfig.root().render(ConfigRenderOptions.concise().setFormatted(true))) print my config content.But I find it contains many other information, such as "version" : "2.4.16", "stdout-loglevel" : "WARNING",etc, which is not defined in my config file.
Where is the info come from?
How can I just print my config file contents?
how to use typesafe config library just render file content?
1.5k views Asked by LoranceChen At
3
There are 3 answers
0
On
I use a way to render config with parseResourcesAnySyntax method by separate myConfig with default:
object DataServiceConfig {
val local = ConfigFactory.parseResourcesAnySyntax("local")
val online = ConfigFactory.parseResourcesAnySyntax("online")
val develop = ConfigFactory.parseResourcesAnySyntax("application") //develop environment
val default = ConfigFactory.load("application") //default environment
val myConfig = local.withFallback(online).withFallback(develop)
val combinedConfig = myConfig.withFallback(default)
def printConf(config: Config): Unit = println(config.root().render(ConfigRenderOptions.concise().setFormatted(true).setJson(true)))
}
print config: DataServiceConfig.printConf(DataServiceConfig.myConfig)
You're probably using Akka 2.4.16 (directly or indirectly), in which case the "extra" configuration settings are pulled from the
reference.conf, as described in the documentation. Thereference.confcontains all the default configuration settings, and yourapplication.confcan override any of those settings.The
ActorSystemmerges thereference.confwith yourapplication.conf, as seen here. I don't think there is a way through the Typesafe Config API to render the contents of yourapplication.confwithout including the merged settings fromreference.conf.