How do I write to the console in Google App Engine?

You'll want to use the Python's standard logging module.

import logging

logging.info("hello")
logging.debug("hi") # this won't show up by default

To see calls to logging.debug() in the GoogleAppEngineLauncher Logs console, you have to first add the flag --dev_appserver_log_level=debug to your app. However, beware that you're going to see a lot of debug noise from the App Engine SDK itself. The full set of levels are:

  • debug
  • info
  • warning
  • error
  • critical

You can add the flag by double clicking the app and then dropping it into the Extra Flags field.

Adding the --dev_appserver_log_level flag to your app in the GoogleAppEngineLauncher


See https://cloud.google.com/appengine/docs/python/requests#Python_Logging
and http://docs.python.org/library/logging.html

You probably want to use something like:

logging.debug("value of my var is %s", str(var))

@Manjoor

You can do the same thing in java.

import java.util.logging.Logger;
// ...

public class MyServlet extends HttpServlet {
    private static final Logger log = Logger.getLogger(MyServlet.class.getName());

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {

        log.info("An informational message.");

        log.warning("A warning message.");

        log.severe("An error message.");
    }
}

See "Logging" in http://code.google.com/appengine/docs/java/runtime.html


If you're using a more recent version of the Python Development Server (releases > 1.7.6, or Mar 2013 and later), these seem to be the right steps to use:

  1. Include the following in your script,

    import logging logging.debug("something I want to log")

  2. And per this docs page, set a flag by going to Edit > Application Settings > Launch Settings > Extra Command Line Flags, and adding,

    --log_level=debug


You should also give FirePython a look. It allows you to get server log messages in firebug.

http://appengine-cookbook.appspot.com/recipe/firepython-logger-console-inside-firebug/