When a request is sent to your application running in App Engine, request and response details are logged automatically, and can be viewed in the Google Cloud Platform Console Logs Viewer.
When your application handles a request, it can also
write its own logging messages to
stderr. These files are
automatically collected and can be viewed in the Logs Viewer. Only the most
recent entries to
stderr are retained, in order
to limit their size.
The request and application logs for your app are collected by a Cloud Logging agent and are kept for a maximum of 90 days, up to a maximum size of 1GB. If you want to store your logs for a longer period or store a larger size than 1GB, you can export your logs to Cloud Storage. You can also export your logs to BigQuery and Pub/Sub for further processing.
Other logs are also available for your use. See Runtime logs for a listing of these.
In addition to App Engine-generated request logs, apps running in the flexible environment can write additional logs. The following are some of the logs that are configured by default:
||Shows audit log information.|
||Shows nginx logs specifically for health checks. Reduces noise in the request logs.|
||Shows logs from the nginx proxy as they are passed through to the app.|
||Standard output from your app.|
||Standard error from your container.|
||Information logged when setup fails. If your application fails to run, check this log.|
||Information logged on shutdown.|
||The VM syslog, outside of the Docker container.|
Writing application logs
Write your application logs using
stdout for output and
stderr for errors.
Note that this does not provide log levels that you can use for filtering
in the Logs Viewer; however, the Logs Viewer does provide other filtering, such
as text, timestamp, etc.
To view logs written by apps running in the flexible environment, use the Logs Viewer:
Visit the Logs Viewer page in the Google Cloud Platform Console.
From the log type pulldown menu, pick the log type (
vm.crash, etc.), that you want to view.
Use the desired filter to retrieve the logs you want to see. You can filter by various combinations of time, log level, module, and log filter label or regular expression.
Notice that labels are regular expressions for filtering the logs by logging fields. Valid labels include the following:
path:/foo.* useragent:.*Chrome.*gets logs for all requests to a path starting with
/foothat were issued from a Chrome browser.
Reading logs via API
There is no API for reading App Engine logs created in the flexible environment.