Configuration Files Walkthrough

In this walkthrough, you'll look at the configuration files used in the Guestbook project:

  • The pom.xml file fully configures the project with everything needed to build and run.
  • The web.xml is used for the servlet mappings.
  • The appengine-web.xml is used for deployment.
  • The logging.properties file is used for setting application logging behavior.

This page is part of a multi-page tutorial. To start from the beginning and see instructions for setting up, go to Creating a Guestbook.

Specifying application and SDK versions in pom.xml

To run the sample, you don't need to change anything in the pom.xml. In your own applications, you need to change several values, such as:

  • <appengine.app.version>, which sets the application version.
  • <appengine.sdk.version>, which sets the App Engine SDK version for Java.
  • <objectify>, <guava>, and <maven>, which set the versions of their respective tools.

Specifying deployment project ID in appengine-web.xml

To test the sample locally, you don't need to specify the project ID (also called application ID in App Engine).

However, before you can deploy to production, you must specify which project you are deploying to. You do this by setting the <application> value to the project ID you obtained when you created your project in the console, replacing the value your-app-id with your project ID.

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application>your-app-id</application>
    <version>${appengine.app.version}</version>
    <threadsafe>true</threadsafe>

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    </system-properties>
</appengine-web-app>

Specifying default application log level in logging.properties

By default, the log level set for your application is Warning, as shown below:

# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
# 
# <system-properties>
#   <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#

# Set the default logging level for all loggers to WARNING
.level = WARNING

This suppresses Info messages from the log output. If you want to change the log level for all classes in your app, change this level. For example you could change .level = Warning to .level = Info.

Specifying servlet mapping in web.xml

You don't need to make any changes in web.xml to run and deploy this sample code. There are a few things you should note about the following web.xml file from the sample:

<servlet>
  <servlet-name>sign</servlet-name>
  <servlet-class>com.example.guestbook.SignGuestbookServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>sign</servlet-name>
  <url-pattern>/sign</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>guestbook.jsp</welcome-file>
</welcome-file-list>

Notice that the guestbook.jsp page is specified as the main page for the app, and that the servlet serves at the URL /sign.

You will learn more about the Objectify portions of this file in Storing Data with Objectify and Cloud Datastore.