简体   繁体   English

登录Google Cloud端点

[英]Logging in a Google Cloud Endpoint

I need to debug my Google Cloud Endpoint after it is deployed to AppEngine. 我需要在部署到AppEngine后调试我的Google Cloud Endpoint。 I am trying to write entries to the log but they never show up in the log viewer on the Google Developers Console. 我正在尝试将条目写入日志,但它们从未显示在Google Developers Console的日志查看器中。 Here is the logging code I created in Android Studio: 这是我在Android Studio中创建的日志代码:

import java.util.logging.Logger;
...
public class MyEndpoint {
    private static final Logger log = Logger.getLogger(MyEndpoint.class.getName());
...
log.info("message to log");

This code executes in the cloud without error but nothing shows up in the log. 此代码在云中执行而没有错误,但日志中没有显示任何内容。 What am I doing wrong? 我究竟做错了什么?

The entry is not showing in the log because the default logging level in app engine is: WARNING. 该条目未显示在日志中,因为app引擎中的默认日志记录级别为:警告。 Setting the logging level prior to calling log.info() caused the log entry to show in the console as expected. 在调用log.info()之前设置日志记录级别会导致日志条目按预期显示在控制台中。 Here is the revised code with setLevel in context: 以下是在上下文中使用setLevel的修订代码:

import java.util.logging.Logger;
...
public class MyEndpoint {
    private static final Logger log =Logger.getLogger(MyEndpoint.class.getName());
...
log.setLevel(Level.INFO);
log.info("message to log");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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