Configuring your application via application.conf

Though Play does not require a lot of configuration to run, there has to be one file where basic information such as database connection strings, log levels, modules to enable additional functionality, supported application languages, or the setting of the application mode is configured. This file is conf/application.conf , though it looks like a properties file, it really is not because of its UTF-8 encoding.

How to do it...

Just open conf/application.conf with your any editor supporting UTF-8, be it Eclipse, Vim, textmate, or even notepad.

Now every configuration option follows the scheme:

# Some comment
key = value

Notable for application start is the http.port option, which runs your Play application per default on port 9000; this can be changed to any port above 1024 if you are a non-root user, which is highly recommended anyway.

How it works...

By definition Java property files are ISO-8859-1 and nothing else. Play, however, is thought of as an everything-UTF-8 framework; hence, the application configuration filename does not have a .properties suffix. For more info about standard Java properties, please refer to:

http://download.oracle.com/javase/6/docs/api/java/util/Properties.html

As the documentation covers most of the possible parameters in the configuration file pretty well, this file will only be mentioned if the default configuration has to be changed.

Most importantly, adding and configuring modules in order to enhance the basic functionality of Play is part of the application.conf, and each module requires enabling it via defining its path:

module.foo=${play.path}/modules/foo

After starting your Play application, the console output should include information about which of your configured modules have been loaded successfully.

Note

Please be aware that from play 1.2 modules are not configured via this mechanism, but via the new dependencies.yml file. You can still configure modules this way, but this is deprecated from then on.

Another important setup is the log level of your application when using log4j, which is used by Play framework all over the place. When in production mode, it should be set to INFO or ERROR; however, in testing mode the following line might help you to discover problems:

application.log=DEBUG

See also

We will refer to the application.conf file when setting up special databases later on in this chapter. Also there is an own Configuring log4j for log rotation recipe in the Chapter 7, Running in Production.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.12.156