Akka makes use of HACON (Human-Optimized Config Object Notation) for configuration. Today I needed to check the config that was loaded. When printing the config to the terminal it is displayed in a compact format. I wanted to pretty print it so it was easier to read. I found a briljant blog post by marcinkubala.
I adapted a code snippet as follows:
val renderOpts = ConfigRenderOptions.defaults().setOriginComments(false).setComments(false).setJson(false) val config = ConfigFactory.load("application.conf") println(config.root().render(renderOpts))
Makes life a lot easier if you can actually read what is in a config 🙂
In Akka it is not necessary to load the configuration separately like I did above. You can pretty print the configuration loaded by the ActorSystem:
val config = ConfigFactory.load("application.conf") val renderOpts = ConfigRenderOptions.defaults().setOriginComments(false).setComments(false).setJson(false) println(system.settings.config.root().render(renderOpts))
In the blog post marcinkubala also points out it really easy to integrate configuration HACON style in your own projects.