Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where I can see the logs in Google App Engine?

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

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

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

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.

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.

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.

like image 646
Sharad Soni Avatar asked Mar 03 '18 23:03

Sharad Soni


1 Answers

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

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

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.

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).

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

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

Logging > Logs

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.

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.

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.

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.

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

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.

like image 84
neilH Avatar answered Oct 31 '22 21:10

neilH