Reviewing logs with the Stackdriver Logs Viewer

This document provides information on how to use the Stackdriver Logs Viewer to review logs.

Before you begin

  • Configure your application to use the Stackdriver Logging API.

  • Sign in your account to access Google Cloud platform resources.

    • Select Tools -> Google Cloud Tools -> Manage Accounts... to select your account.

Accessing Logs Viewer

To access Stackdriver Logs Viewer, select Tools -> Google Cloud Tools -> Show Stackdriver Logs Viewer.

The Google Stackdriver Logging tab opens.

Or, you can open the Logs Viewer for a specific project from Google Cloud Explorer by selecting Tools -> Google Cloud Tools -> Google Cloud Explorer. Right click the project and select Browse Stackdriver Logs.

Image showing the overview of the Logs Viewer tab

Getting around the interface

The Logs Viewer interface has the following major components:

  • A search bar to filter log entries by label or text search.

  • Drop down menus to filter the list by resources, logs, and severity levels.

  • Jump to time drop down menu to view a specific date and time in the logs.

  • A Refresh button to retrieve the latest logs in descending order.

  • Auto load log stream controls whether or not to display new log entries as they arrive.

    • Clicking Play starts the stream of the latest logs. The stream will stop if you scroll the logs display.

    • Clicking Pause stops the logs stream.

  • The table of log summaries that you can click to view the full details for individual log entries.

  • An Expand all down arrow at the top right corner of the log entries panel to show the details of all log entries. This action may take some time if the panel has a lot of log entries.

  • If available, a source link to locate the source code that generates the log entry.

Logs Viewer allows you to navigate to the source code that generates a log entry. To enable this feature, you should build your project from a local git repository, and you must add source location information to log entries.

Adding source location to your log

Configure your application to provide source code location information in the logs:

  1. Write location information for the log entries using the following sample from GitHub.

  2. Deploy a source_context.json file at the root of the application.

    If you publish the solution via the Google Cloud Tools for Visual Studio extension, the extension automatically generates and deploys the file. Or you can generate the file yourself following the generate the source context file instructions.

After you complete these steps, the log entries contain a sourceLocation field with File and Line information. The optional Function line can contain the assembly name, version, or function name.

Image showing expanded log entry and a link to navigate to the source code

Clicking the source link navigates to the source code if the source file is accessible.

Image showing source code accessed from link in log entry

Viewing the logs

In the Logs Viewer interface, you can filter the log entries or search for specific logs to display.

Filtering the logs

You can filter the log entries to see only those logs you are interested in.

  • In the resource type and instance drop-down menu, you can select all instances of a particular resource type you wish to see, or view a specific instance. For a list of resource types, see the Monitored Resources and Services.

  • In the log type drop-down menu, select the named logs you want to view or select All logs. The menu only shows the logs that the selected resource generates.

  • In the log severity drop-down menu, select the severity level you want to view. Selecting All log levels includes log entries that do not have a severity level.

  • In the Jump to time drop-down menu, select a date and time. Choose if you want to see logs before or after the selected timestamp.

You can also click To Advanced Filter to access the advanced filter bar where you can filter the log entries through queries. Click the Advanced filter help link for more information.

Image showing the advanced filter bar

Searching the logs

In the search bar, search for keywords that appear in the log entries.

Image showing search results

Showing similar logs

You can click the value of an individual field in the expanded log entry view and then either show or hide all log entries with the same value.

Image showing how to click to find similar log entries

When you show similar log entries, the advanced filter bar displays, where you can edit the filter and click Submit Filters. Click the Advanced filter help link for more information.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Tools for Visual Studio