Documentation

You are viewing the documentation for the 2.0.3 release in the 2.0.x series of releases. The latest stable release series is 3.0.x.

§Additional configuration

When running an application in production mode you can override any configuration. This section covers the more common use cases.

All these additional configurations are specified using Java System properties and can be used directly if you are using one of the start script generated by Play.

§Specifying the HTTP server address and port

You can provide both HTTP port and address. The default is to listen on port 9000 at the 0.0.0.0 address (all addresses).

$ start -Dhttp.port=1234 -Dhttp.address=127.0.0.1

Note that these configuration are only provided for the default embeded Netty server.

§Specifying additional JVM arguments

You can specify any JVM arguments to the start script. Otherwise the default JVM settings will be used:

$ start -Xms128M -Xmx512m -server

§Specifying alternative configuration file

The default is to load the application.conf file from the classpath. You can specify an alternative configuration file if needed:

§Using -Dconfig.resource

It will search for an alternative configuration file in the application classpath (you usually provide these alternative configuration files into your application conf/ directory before packaging).

$ start -Dconfig.resource=prod.conf

§Using -Dconfig.file

You can also specify another local configuration file not packaged into the application artifacts:

$ start -Dconfig.file=/opt/conf/prod.conf

§Using -Dconfig.url

You can also specify a configuration file to be loaded from any URL:

$ start -Dconfig.url=http://conf.mycompany.com/conf/prod.conf

Note that you can always reference the original configuration file in a new prod.conf file using the include directive, such as:

include "application.conf"

key.to.override=blah

§Overriding specific configuration keys

Sometimes you don’t want to specify another complete configuration file, but just override a bunch of specific keys. You can do that by specifying then as Java System properties:

$ start -Dapplication.secret=verysecretkey -Ddb.default.password=toto

§Using environment variables

You can also reference environment variables from your application.conf file:

my.key = defaultvalue
my.key = ${?MY_KEY_ENV}

Here, the override field my.key = ${?MY_KEY_ENV} simply vanishes if there’s no value for MY_KEY_ENV, but if you set an environment variable MY_KEY_ENV for example, it would be used.

§Changing the logback configuration file

You can also specify another logback configuration file via a System property.

§Using -Dlogger.resource

Specify another loback configuration file to be loaded from the classpath:

$ start -Dlogger.resource=conf/prod-logger.xml

§Using -Dlogger.file

Specify another loback configuration file to be loaded from the file system:

$ start -Dlogger.file=/opt/prod/logger.xml

§Using -Dlogger.url

Specify another loback configuration file to be loaded from an URL:

$ start -Dlogger.url=http://conf.mycompany.com/logger.xml