Deepak Tiwari, Doug Anderson
Google Cloud Logging provides facilities for importing, viewing, storing, and retrieving logs from applications running on the Google Cloud Platform.
What is available
Google Cloud Logging includes the following features for App Engine:
- Request logs and application logs for App Engine applications.
- Custom log files for applications using Managed VMs.
- A Logs API (Python, Java, PHP, Go) for accessing logs.
Cloud Logging and Managed VMs apps
Applications using App Engine Managed VMs should write custom log files to
the VM's log directory at
/var/log/app_engine/custom_logs. These files
are automatically collected and made available in the Logs Viewer.
Custom log files must have the suffix
.log.json. If the suffix is
.log.json, the logs must be in JSON format with one JSON object per line. If
the suffix is
.log, log entries are treated as plain text.
Runtime logs for Managed VMs
App Engine Managed VMs can write additional logs from the VM runtimes. Following are some of the logs that are configured by default:
|Log name||Payload type||Purpose|
||text||Information logged when setup fails.|
||text||Information from the Google Docker container publishing data to Cloud Monitoring.|
||text||Information logged on shutdown.|
||text||Standard output from your app.|
||text||Standard error from your container.|
||text||The VM syslog, outside of the Docker container.|
Using the Logs Viewer
The Logs Viewer provides a web-based UI to navigate, display, and search your logs. With the Logs Viewer you can view and search logs from all your instances and apply filters to narrow in on a specific event, regardless of where it was generated.
To view logs:
In the Google Cloud Platform Console, go to the Logging page.
Ensure that App Engine is selected in the dropdown menu.
If your app runs in a Managed VM and writes custom logs, select the desired log name.
Filtering and finding logs
You can choose to view only those logged events that are above a certain severity. Debug events are considered the lowest severity, Critical events are considered the highest. For instance, if you select a minimum severity of 'Warning', all warning, error, and critical log events will be displayed.
When viewing the Request log,
you can combine field filters (for example,
protocol:, and so forth) and
regular expressions in the same query, using the filter text box in the
Logs Viewer. In addition, you can add and
remove filters to help drill down and then zoom out again until you find what
you’re looking for. Simply modify the query and press Enter to refresh the logs.
When you click the search bar, the Logs Viewer shows possible completions for filter fields as you type.
Filters of the same type are ORed together, while different
filter types are ANDed together. So for example,
status:400 status:500 regex:quota would produce all requests that returned
HTTP status of either
500, AND have the word
quota in the log.
Field filters aren't yet supported for Managed VM custom logs, but you can use regular expressions to search custom logs.
Search or scroll through all of your logs
When you scroll through your logs in the new Logs Viewer, results are fetched until the console window is full. To retrieve additional logs that match the query, scroll down for newer results or up for older ones.
This provides you with a continuous view of your events to enable you to move forward and backward in time without requiring you to click Next or refresh the console. While results are being fetched you will see a Loading… indicator at the top or bottom of the viewer.
You can also click the refresh icon to load the latest logs, or click the play icon to live stream the logs for all of your logs from all of your instances.