简体   繁体   中英

Where can I see App logs which I have written in java app in google cloud platform?

import java.util.logging.Logger;
@WebServlet(name = "HelloAppEngine", value = "/hello")

    public class HelloAppEngine extends HttpServlet {
    
           private static final Logger log = Logger.getLogger(HelloAppEngine.class.getName());
          
      @Override
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws IOException {
              log.info("This information log message for doGet");
        Properties properties = System.getProperties();
    
        response.setContentType("text/plain");
        response.getWriter().println("Hello App Engine - Standard using "
                + SystemProperty.version.get() + " Java "
                + properties.get("java.specification.version"));
      }
    
      public static String getInfo() {
          log.info("This information log message for getInfo.");
        return "Version: " + System.getProperty("java.version")
              + " OS: " + System.getProperty("os.name")
              + " User: " + System.getProperty("user.name");
      }

In this java sample code, I have written log messages

I have added files in webapp/WEB-INF/appengine-web.xml

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <runtime>java8</runtime>
  <threadsafe>true</threadsafe>

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

and file webapp/WEB-INF/logging.properties

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

after project deploy the project is running well app view

But I can't able to see the app logs in https://console.cloud.google.com/projectselector2/logs/viewer?

just I'm able to see some request logs logging view page

You have set your log level to WARNING . Only warning, error and fatal (or critical) level will be displayed. Others are skipped.

Change the level to INFO, DEBUG or TRACE in the webapp/WEB-INF/logging.properties file, if you want to see your logs in

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM