You can include annotations in your traces that let you associate a
trace with a Cloud Logging
For more information on annotations, see
Associating a trace with a log entry
When you use the Trace client libraries, or when you use the
OpenCensus library for Python or for Java,
you can associate a trace with a log entry by setting the
trace field in the
trace field must be set to a string with the following format:
[PROJECT_ID] is your Google Cloud project ID and
[TRACE_ID] is the trace identifier
You can associate a span with a log entry by setting the
span_id field in
LogEntry object. In this case,
span_id field to the 16-character hexadecimal encoding of the
span's ID. For example, a span with an ID of
74 is represented as
000000000000004a. When you are using trace sampling, set the
trace_sampled field in the
LogEntry object to indicate that the
trace was sampled for storage when the log entry was written. It's possible that
a log entry is created when the trace itself isn't captured.
- If you are using Python and OpenCensus, for more information on the integration with Cloud Logging, see OpenCensus logging integration.
- If you are using Java and OpenCensus, see OpenCensus Log Correlation.
- If you are using the Cloud Logging agent, see Cloud Logging agent configuration.
You can view the log entry for a trace alongside the waterfall graph or
in the Logs Explorer. When you use the Logs Explorer, it's automatically restricted
to the timestamp range of the trace. If there are no log entries to display,
the Logs Explorer displays the message
No entries found matching current filter.
From the Trace details pane, to view the log entry for the trace, do one of the following:
To display the trace log entries alongside the waterfall graph, go to the waterfall graph and click Show logs. When Show logs isn't displayed, no log entries are available.
To view the log entry in the Logs Explorer, click View next to the label Log in the Details section. Note that when you have a Cloud Load Balancing trace, click View next to the label VM Log.
For more information about viewing log entries in Cloud Logging, see Viewing logs.
Log viewing permissions
To view any log entries, you must have the
in your project. This permission is provided by the Logs Viewer and
Project Viewer Identity and Access Management (IAM) roles.
To view VM instance logs, you must have the
in your project. This permission is provided by the Compute Engine Network
Viewer and Project Viewer IAM roles.