To see the log messages,

1. You should add the following to Appengine-web.xml:

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

2. In the logging.properties file, change .level = WARNING to .level = INFO.

In your code, use java.util.logging.Logger as shown below.

import java.util.logging.Logger;

public class MyClass {
  private static final Logger log = Logger.getLogger(MyClass.class.getName());
  log.info("log message");
  // ...

Users can't use Google Cloud's file system, so they can't stack logs to files. Users can only see log messages at https://console.cloud.google.com/logs.

Using logs in the Guestbook example


import java.util.logging.Logger;

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

  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    Greeting greeting;

    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    String guestbookName = req.getParameter("guestbookName");
    String content = req.getParameter("content");
    if (user != null) {
      log.info("Google User: " + user.getUserId() + ":" + user.getEmail() + ":" + user.getNickname());
      greeting = new Greeting(guestbookName, content, user.getUserId(), user.getEmail());
    } else { 
      greeting = new Greeting(guestbookName, content);
    // Use Objectify to save the greeting and now() is used to make the call synchronously as we
    // will immediately get a new page using redirect and we want the data to be present.

    resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName);

Visit https://your-app-id.appspot.com/guestbook.jsp?guestbookName=default. Click Sign In to sign in to your Google Account. After publishing the guestbook, visit https://console.cloud.google.com/logs to confirm log messages.

GAE Logging Test

For local tests, the command prompt outputs log messages.