Skip to content
rjmac edited this page Apr 18, 2013 · 1 revision

The Propertizer turns a com.typesafe.config.Config object into a java.util.Properties. The intention is to allow Log4j configuration to be stored in the standard configuration file without going through a huge amount of work to write a proper Configurator.

The one trick here is that Log4j frequently uses a property name both for a value and as a root for nested properties. This isn't a concept that HOCON has. Therefore, a little bit of convention is used to emulate this case. If a key refers to an object with exactly two fields, name (or class, because in Log4j these constructions are frequently used to build an object of some kind) and props, the two fields are ignored when generating the Properties. For example,

blah.blah.name = hello
blah.blah.props {
  a = 1
  b = 2
}

will generate the properties

blah.blah=hello
blah.blah.a=1
blah.blah.b=2

You can also provide a prefix for property-names. If it is not the empty string, it is prepended together with a dot on all the generated properties.

Clone this wiki locally