Write logs
To write logs to Cloud Logging, you can do any of the following:
- Write your logs to existing log files such as
syslog
on your Compute EngineVM instance and use the Ops Agent to send the logs to Cloud Logging. For more information, see Google Cloud Observability agents. - Configure a standard logging package to send the logs you write to Logging. For more information, see the following detail pages:
- Call the Logging API using Logging's Client Libraries for your programming language.
- Call the Logging API REST endpoint directly. See the Logging API reference documentation.
- Use the gcloud CLI. For more information,
see the
gcloud logging
command-line interface.
Associate trace data with log entries
Log entries can contain information about traces. By including trace data in log entries, you can correlate logs and traces to enable better distributed troubleshooting. For information about manual and automatic capture of trace information in log entries, see Integrate with Cloud Logging.
Read logs
To read log entries in Logging, you can do any of the following:
-
In the Google Cloud console, go to the Logs Explorer page:
If you use the search bar to find this page, then select the result whose subheading is Logging.
For more information, see Logs Explorer overview.
Call the Logging API through the client libraries for your programming language.
Call the Logging API REST endpoints directly. See the Logging API reference documentation.
Use the gcloud CLI. For more information, see the
gcloud logging
command-line interface.