在哪里可以查看Google App Engine中的日志? [英] Where I can see the logs in Google App Engine?

查看:85
本文介绍了在哪里可以查看Google App Engine中的日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是GAE的新手,因此对于GAE的专家来说,这个问题可能很容易.

I am new to GAE, and hence this question may be very easy for the experts in GAE.

我有Flexible App Engine,MySQL 2nd Gen 5.7的SQL实例

I have Flexible App Engine, SQL instance of MySQL 2nd Gen 5.7

我已将我的laravel应用程序托管在GAE上,并按照以下教程操作:在Google App Engine灵活环境中运行Laravel

I have hosted my laravel app on the GAE, and after following the tutorial: Run Laravel on Google App Engine Flexible Environment

我无法正确获得首页,出现500错误,我的应用程序URL:关于蔬菜的信息

I am unable to get the first page properly, I am getting 500 Error, my app URL: Its About Veg

我想像在本地机器上那样检查错误,但是我无法获取正确的日志.

I want to investigate the error, as I can do on my local box, but I am unable to get the proper logs.

我发现它可以从 https://console.cloud.google.com/logs/viewer?project=project-id URL提供500响应,但我无法获取错误的正确堆栈跟踪,我在这里得到的唯一是某种 JSON 数据.

I figured it out that it gives 500 Response from the https://console.cloud.google.com/logs/viewer?project=project-id URL, but I am unable to get the proper stack trace of the error, the only thing I am getting here is some kind of JSON data.

此外,我还想从服务器上下载日志文件,以便可以手动检查日志并解决问题,但是but!我也找不到.

Moreover, I thought to download the log file from the server, so that I can manually check the logs and resolve the issue, but alas! I am unable to find that too.

在这种情况下,您能帮我什么吗?

Can you please help me out in this context.

推荐答案

有很多方法可以从App Engine检索日志.

There are a number of methods for retrieving logs from App Engine.

您可以尝试 gcloud应用程序日志 命令检索您的应用程序的日志.例如,要将日志输出到终端,可以运行:

You can try the gcloud app logs command to retrieve logs for your application. For example to output the logs into your terminal you could run:

$ gcloud app logs read

或者流式传输日志,您可以运行:

Or to stream the logs you can run:

$ gcloud app logs tail

还可以将日志数据从应用程序下载到本地计算机上的文件中.如果您安装适用于PHP的App Engine SDK ,则可以运行 appcfg.py request_logs 命令,该命令可让您下载日志.有关如何执行此操作的说明,建议您在此处查看.

It's also possible to download the log data from your application to a file on your local computer. If you install App Engine SDK for PHP you are able to run the appcfg.py request_logs command, which will allow you to download the logs. For instructions on how to do this, I would recommend taking a look here.

您还可以使用GCP日志记录页面执行一些细粒度的搜索(有一种导出这些日志的下载方法,我将在下面详细介绍).

You can also perform some fine grained searches using GCPs logging page (there is a method to export download these logs which I will detail below).

登录Google Cloud Platform for App Engine,以及所有其他Google Cloud Platform资源都可以在Stackdriver Logging中查看.

Logs in Google Cloud Platform for App Engine, and all other Google Cloud Platform resources can be viewed in Stackdriver Logging.

要在控制台中导航到Stackdriver Logging,请导航至:

To navigate to Stackdriver Logging in the Console, navigate to:

记录>日志

在那里,您将找到几个下拉菜单.在第一个中,您将能够选择要查看其日志的Google Cloud Platform资源.

Once there, you will find several drop-down menu's. In the first one, you will be able to select the Google Cloud Platform resource you would like to view logs for.

在此下拉菜单中,选择 GAE应用程序.这将确保第二个下拉菜单中填充有可从您的GAE应用程序中查看的各种日志的名称.例如,您可以在此菜单中指定nginx.error或syslogs来过滤特定日志.

In this drop-down menu, select GAE Application. This will ensure the second drop-down menu populates with the names of various logs available for viewing from your GAE Applications. For example, you can specify nginx.error or syslogs in this menu to filter specific logs.

您的应用程序日志文件中的日志将流式传输到Stackdriver日志中,因此它们实质上包含与应用程序日志相同的信息,尽管采用JSON格式以确保它们可读.

Logs from you applications log files are streamed into Stackdriver logging so they essentially contain the same information as the application logs, albeit in JSON format to ensure they are readable.

同样,您可以过滤CloudSQL日志.为此,请在第一个下拉菜单中选择Cloud SQL数据库,然后指定要检查的数据库.

Likewise, you can filter the CloudSQL logs. To do this, in the first drop-down menu, select Cloud SQL Database, and specify the database you would like to check.

日志记录视图中的其他下拉菜单允许您选择各种日志级别(例如错误",警告",严重"等)和时间设置,以使您可以确定时间/日期的特异性粒度搜索.

The other drop-down menu's in the logging view allow you to select various log-levels (for example 'Error', 'Warning', 'Critical' etc) and time settings that allow you to specificity times/dates for finer granularity searches.

您还可以选择在Stackdriver Logging搜索栏中键入搜索字符串,然后使用它们来过滤显示的日志.

You also have the option of typing search strings in the Stackdriver Logging search bar and using them to filter the displayed logs.

如果您想下载这些日志,可以选择创建一个到Google Cloud Storage的日志接收器.这实际上使您可以编写过滤器(针对您感兴趣的日志)并将日志导出到Cloud Storage.如果需要,您可以选择从Cloud Storage下载日志.

If you would like to download these logs, an option would be to create a log sink to Google Cloud Storage. This essentially allows you to write a filter (for the logs you are interested in) and export the logs to Cloud Storage. If required, you would then have the option to download the logs from Cloud Storage.

此处

There is some useful information here and here about setting up a log sink.

这篇关于在哪里可以查看Google App Engine中的日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆