load the normal config stack (system props, You can also combine your custom config with the usual config, that might look like: // make a Config with just your special settingĬonfig m圜onfig = ConfigFactory.parseString("something=somethingElse")
For example you could put a config string in code using ConfigFactory.parseString() or you could make a map and ConfigFactory.parseMap(), or you could load a file. The most flexible variant takes a Config object, which you can load using any method in ConfigFactory. Scala> ConfigFactory.parseString("a.b=12") Type in expressions to have them evaluated. If in doubt, you can inspect your configuration objects before or after using them to construct an actor system: Welcome to Scala 2.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0). This is useful when you are uncertain of what configuration is used. If the system or config property akka.log-config-on-start is set to on, then the complete configuration is logged at INFO level when the actor system is started. More advanced include and substitution mechanisms are explained in the HOCON specification. Specifying system property with -Dconfig.resource=/dev.conf will load the dev.conf file, which includes the nf dev.conf include "application" Sometimes it can be useful to include another configuration file, for example if you have one nf with all environment independent settings and then override some settings for specific environments. # Throughput for default Dispatcher, set to 1 for as fair as possible # publishing log events to the eventStream. # Filter of log events that is used by the LoggingAdapter before # This logger prints the log messages to stdout (System.out). # Log level for the very basic logger activated during ActorSystem startup. # Options: OFF, ERROR, WARNING, INFO, DEBUG
# as they have been started before that, see "stdout-loglevel" # Log level used by the configured loggers (see "loggers") as soon # Loggers to register at boot time ($DefaultLogger logs # Copy in parts of the reference files and modify as you please. The plugin configuration might look like this: Ī custom nf might look like this: # In this file you can override any option defined in the reference files. If you are using Maven to package your application, you can also make use of the Apache Maven Shade Plugin support for Resource Transformers to merge all the nfs on the build classpath into one. Otherwise all defaults will be lost and Akka will not function. Unfortunately this also means that if you put/merge multiple jars into the same jar, you need to merge all the nfs as well. Also noteworthy is that the application configuration-which defaults to application-may be overridden using the config.resource property (there are more, please refer to the Config docs).Īkka’s configuration approach relies heavily on the notion of every module/jar having its own nf file, all of these will be discovered by the configuration and loaded. Highest precedence is given to overrides given as system properties, see the HOCON specification (near the bottom). The philosophy is that code never contains default values, but instead relies upon their presence in the nf supplied with the library in question. it internally uses appConfig.withFallback(faultReference(classLoader)) The actor system then merges in all nf resources found at the root of the class path to form the fallback configuration, i.e. This means roughly that the default is to parse all nf, application.json and application.properties found at the root of the class path-please refer to the aforementioned documentation for details.
While constructing an actor system, you can either pass in a Config object or not, where the second case is equivalent to passing ConfigFactory.load() (with the right class loader). Where configuration is read fromĪll configuration for Akka is held within instances of ActorSystem, or put differently, as viewed from the outside, ActorSystem is the only consumer of configuration information. If you use Akka from the Scala REPL from the 2.9.x series, and you do not provide your own ClassLoader to the ActorSystem, start the REPL with “-Yrepl-sync” to work around a deficiency in the REPLs provided Context ClassLoader.