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 Console Stackdriver Logging Logs Viewer.See Quotas and limits for the logs retention policy and for the maximum size of log entries. If you want to store your logs for a longer period, you can export your logs to Cloud Storage. You can also export your logs to BigQuery and Pub/Sub for further processing.
Writing application logs
When your application handles a request, it can write its own logging messages
stderr. Write your application logs using
stdout for output
stderr for errors. These files are automatically collected and can be
viewed in the Logs Viewer. 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. Only the most recent entries in
the Logs Viewer are retained in order to limit their size.
console.error()functions, which have the following log levels:
- Items emitted with
console.log()have the INFO log level.
- Items emitted with
console.error()have the ERROR log level.
- Internal system messages have the DEBUG log level.
For Node.js apps, you can optionally use the Bunyan or Winston plugins, or use the Stackdriver Logging Client Library for Node.js directly. For more information, see Setting Up Stackdriver Logging for Node.js.
Viewing application logs
You can view your application logs using the Logs Viewer:
Go to the Stackdriver > Logging page in the Cloud Console:
Select an existing Google Cloud project at the top of the page.
From the drop-down menus, select GAE Application as your resource type to see your App Engine logs.
You can use the drop-down menus and other components of the Logs Viewer to filter or search the logs for relevant entries. See Logs Viewer filter interfaces for more details.
Filtering application logs
To filter log entries by label or text search in the Logs Viewer, see Viewing logs.
Viewing related request log entries
In the Logs Viewer, log entries correlated by the same
trace can be viewed in
a "parent-child" format.
See the GitHub documentation for instructions for correlating log entries.
Once you have correlated the log entries, following are instructions for viewing correlated log entries:
Open your App Engine logs in the Logs Viewer; for details, see Viewing application logs.
requestlog by clicking the small black triangle to the left of the log entry. You see your
requestand app logs displayed in a nested format.
- The highest
severityfrom the "child" log entries does not automatically apply to the top-level entry. If that behavior is desired, manually set the highest
severityin the top-level entry.
- Set the
httpRequest.requestUrlfield for the top-level log.