This page shows how to get started with the Cloud Client Libraries for the Cloud Logging API. Client libraries make it easier to access Google Cloud APIs from a supported language. Although you can use Google Cloud APIs directly by making raw requests to the server, client libraries provide simplifications that significantly reduce the amount of code you need to write.
Read more about the Cloud Client Libraries and the older Google API Client Libraries in Client libraries explained.
Cloud Logging client libraries are idiomatic interfaces around the API.
Client libraries provide an integration option with Logging.
You can use client libraries in addition to using an agent.
Some Google Cloud services, such as Google Kubernetes Engine,
contain an integrated logging agent that sends the data written
to stdout or stderr as logs to Cloud Logging.
- For App Engine flexible environment and Cloud Run functions, you can use the integrated agent.
- For Compute Engine, you can install an agent that collects both logs and metrics.
- For Android, we recommend that you use Firebase for logging. For more information, see Write and view logs.
To learn more about setting up Logging using a language runtime, see Setting up Language Runtimes.
Incoming log entries with timestamps that are more than the logs retention period in the past or that are more than 24 hours in the future are discarded.
Install the client library
C++
See Setting up a C++ development environment for details about this client library's requirements and install dependencies.
C#
dotnet add package Google.Cloud.Logging.V2
For more information, see Setting Up a C# Development Environment.
Go
go get cloud.google.com/go/logging
For more information, see Setting Up a Go Development Environment.
Java
If you are using Maven with
a BOM, add the following to your pom.xml file: