Appengine-web.xml should have the following added:

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

Open the logging.properties file and 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");
  // ...

You can view the log at https://console.cloud.google.com/logs.
For reference, you can not use Google Cloud's file system. Therefore, you can not use the code to load the log into a file.

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 log in to your Google account and post it.
Visit https://console.cloud.google.com/logs to see the logs.
GAE Logging Test
For local tests, the log message is printed at the command prompt.