Package com.google.cloud.logging.v2 (3.16.2)

A client to Cloud Logging API

The interfaces provided are listed below, along with usage samples.

LoggingClient

Service Description: Service for ingesting and querying logs.

Sample for LoggingClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LoggingClient loggingClient = LoggingClient.create()) {
   LogName logName = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
   loggingClient.deleteLog(logName);
 }
 

ConfigClient

Service Description: Service for configuring sinks used to route log entries.

Sample for ConfigClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConfigClient configClient = ConfigClient.create()) {
   GetBucketRequest request =
       GetBucketRequest.newBuilder()
           .setName(
               LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]")
                   .toString())
           .build();
   LogBucket response = configClient.getBucket(request);
 }
 

MetricsClient

Service Description: Service for configuring logs-based metrics.

Sample for MetricsClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetricsClient metricsClient = MetricsClient.create()) {
   LogMetricName metricName = LogMetricName.of("[PROJECT]", "[METRIC]");
   LogMetric response = metricsClient.getLogMetric(metricName);
 }
 

Classes

ConfigClient

Service Description: Service for configuring sinks used to route log entries.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ConfigClient configClient = ConfigClient.create()) {
   GetBucketRequest request =
       GetBucketRequest.newBuilder()
           .setName(
               LogBucketName.ofProjectLocationBucketName("[PROJECT]", "[LOCATION]", "[BUCKET]")
                   .toString())
           .build();
   LogBucket response = configClient.getBucket(request);
 }
 

Note: close() needs to be called on the ConfigClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
MethodDescriptionMethod Variants

ListBuckets

Lists log buckets.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listBuckets(ListBucketsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listBuckets(BillingAccountLocationName parent)

  • listBuckets(FolderLocationName parent)

  • listBuckets(LocationName parent)

  • listBuckets(OrganizationLocationName parent)

  • listBuckets(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listBucketsPagedCallable()

  • listBucketsCallable()

GetBucket

Gets a log bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getBucket(GetBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getBucketCallable()

CreateBucketAsync

Creates a log bucket asynchronously that can be used to store log entries.

After a bucket has been created, the bucket's location cannot be changed.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createBucketAsyncAsync(CreateBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createBucketAsyncOperationCallable()

  • createBucketAsyncCallable()

UpdateBucketAsync

Updates a log bucket asynchronously.

If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.

After a bucket has been created, the bucket's location cannot be changed.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateBucketAsyncAsync(UpdateBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateBucketAsyncOperationCallable()

  • updateBucketAsyncCallable()

CreateBucket

Creates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createBucket(CreateBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createBucketCallable()

UpdateBucket

Updates a log bucket.

If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.

After a bucket has been created, the bucket's location cannot be changed.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateBucket(UpdateBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateBucketCallable()

DeleteBucket

Deletes a log bucket.

Changes the bucket's lifecycle_state to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all log entries in the bucket will be permanently deleted.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteBucket(DeleteBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteBucketCallable()

UndeleteBucket

Undeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • undeleteBucket(UndeleteBucketRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • undeleteBucketCallable()

ListViews

Lists views on a log bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listViews(ListViewsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listViews(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listViewsPagedCallable()

  • listViewsCallable()

GetView

Gets a view on a log bucket..

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getView(GetViewRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getViewCallable()

CreateView

Creates a view over log entries in a log bucket. A bucket may contain a maximum of 30 views.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createView(CreateViewRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createViewCallable()

UpdateView

Updates a view on a log bucket. This method replaces the following fields in the existing view with values from the new view: filter. If an UNAVAILABLE error is returned, this indicates that system is not in a state where it can update the view. If this occurs, please try again in a few minutes.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateView(UpdateViewRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateViewCallable()

DeleteView

Deletes a view on a log bucket. If an UNAVAILABLE error is returned, this indicates that system is not in a state where it can delete the view. If this occurs, please try again in a few minutes.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteView(DeleteViewRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteViewCallable()

ListSinks

Lists sinks.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listSinks(ListSinksRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listSinks(BillingAccountName parent)

  • listSinks(FolderName parent)

  • listSinks(OrganizationName parent)

  • listSinks(ProjectName parent)

  • listSinks(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listSinksPagedCallable()

  • listSinksCallable()

GetSink

Gets a sink.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSink(GetSinkRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSink(LogSinkName sinkName)

  • getSink(String sinkName)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSinkCallable()

CreateSink

Creates a sink that exports specified log entries to a destination. The export of newly-ingested log entries begins immediately, unless the sink's writer_identity is not permitted to write to the destination. A sink can export log entries only from the resource owning the sink.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createSink(CreateSinkRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createSink(BillingAccountName parent, LogSink sink)

  • createSink(FolderName parent, LogSink sink)

  • createSink(OrganizationName parent, LogSink sink)

  • createSink(ProjectName parent, LogSink sink)

  • createSink(String parent, LogSink sink)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createSinkCallable()

UpdateSink

Updates a sink. This method replaces the following fields in the existing sink with values from the new sink: destination, and filter.

The updated sink might also have a new writer_identity; see the unique_writer_identity field.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSink(UpdateSinkRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSink(LogSinkName sinkName, LogSink sink)

  • updateSink(String sinkName, LogSink sink)

  • updateSink(LogSinkName sinkName, LogSink sink, FieldMask updateMask)

  • updateSink(String sinkName, LogSink sink, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSinkCallable()

DeleteSink

Deletes a sink. If the sink has a unique writer_identity, then that service account is also deleted.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteSink(DeleteSinkRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteSink(LogSinkName sinkName)

  • deleteSink(String sinkName)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteSinkCallable()

CreateLink

Asynchronously creates a linked dataset in BigQuery which makes it possible to use BigQuery to read the logs stored in the log bucket. A log bucket may currently only contain one link.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createLinkAsync(CreateLinkRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • createLinkAsync(LogBucketName parent, Link link, String linkId)

  • createLinkAsync(String parent, Link link, String linkId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createLinkOperationCallable()

  • createLinkCallable()

DeleteLink

Deletes a link. This will also delete the corresponding BigQuery linked dataset.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteLinkAsync(DeleteLinkRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteLinkAsync(LinkName name)

  • deleteLinkAsync(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteLinkOperationCallable()

  • deleteLinkCallable()

ListLinks

Lists links.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLinks(ListLinksRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listLinks(LogBucketName parent)

  • listLinks(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLinksPagedCallable()

  • listLinksCallable()

GetLink

Gets a link.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLink(GetLinkRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getLink(LinkName name)

  • getLink(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLinkCallable()

ListExclusions

Lists all the exclusions on the _Default sink in a parent resource.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listExclusions(ListExclusionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listExclusions(BillingAccountName parent)

  • listExclusions(FolderName parent)

  • listExclusions(OrganizationName parent)

  • listExclusions(ProjectName parent)

  • listExclusions(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listExclusionsPagedCallable()

  • listExclusionsCallable()

GetExclusion

Gets the description of an exclusion in the _Default sink.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getExclusion(GetExclusionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getExclusion(LogExclusionName name)

  • getExclusion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getExclusionCallable()

CreateExclusion

Creates a new exclusion in the _Default sink in a specified parent resource. Only log entries belonging to that resource can be excluded. You can have up to 10 exclusions in a resource.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createExclusion(CreateExclusionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createExclusion(BillingAccountName parent, LogExclusion exclusion)

  • createExclusion(FolderName parent, LogExclusion exclusion)

  • createExclusion(OrganizationName parent, LogExclusion exclusion)

  • createExclusion(ProjectName parent, LogExclusion exclusion)

  • createExclusion(String parent, LogExclusion exclusion)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createExclusionCallable()

UpdateExclusion

Changes one or more properties of an existing exclusion in the _Default sink.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateExclusion(UpdateExclusionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateExclusion(LogExclusionName name, LogExclusion exclusion, FieldMask updateMask)

  • updateExclusion(String name, LogExclusion exclusion, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateExclusionCallable()

DeleteExclusion

Deletes an exclusion in the _Default sink.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteExclusion(DeleteExclusionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteExclusion(LogExclusionName name)

  • deleteExclusion(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteExclusionCallable()

GetCmekSettings

Gets the Logging CMEK settings for the given resource.

Note: CMEK for the Log Router can be configured for Google Cloud projects, folders, organizations and billing accounts. Once configured for an organization, it applies to all projects and folders in the Google Cloud organization.

See Enabling CMEK for Log Router for more information.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getCmekSettings(GetCmekSettingsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getCmekSettingsCallable()

UpdateCmekSettings

Updates the Log Router CMEK settings for the given resource.

Note: CMEK for the Log Router can currently only be configured for Google Cloud organizations. Once configured, it applies to all projects and folders in the Google Cloud organization.

UpdateCmekSettings will fail if 1) kms_key_name is invalid, or 2) the associated service account does not have the required roles/cloudkms.cryptoKeyEncrypterDecrypter role assigned for the key, or 3) access to the key is disabled.

See Enabling CMEK for Log Router for more information.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateCmekSettings(UpdateCmekSettingsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateCmekSettingsCallable()

GetSettings

Gets the Log Router settings for the given resource.

Note: Settings for the Log Router can be get for Google Cloud projects, folders, organizations and billing accounts. Currently it can only be configured for organizations. Once configured for an organization, it applies to all projects and folders in the Google Cloud organization.

See Enabling CMEK for Log Router for more information.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSettings(GetSettingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSettings(SettingsName name)

  • getSettings(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSettingsCallable()

UpdateSettings

Updates the Log Router settings for the given resource.

Note: Settings for the Log Router can currently only be configured for Google Cloud organizations. Once configured, it applies to all projects and folders in the Google Cloud organization.

UpdateSettings will fail if 1) kms_key_name is invalid, or 2) the associated service account does not have the required roles/cloudkms.cryptoKeyEncrypterDecrypter role assigned for the key, or 3) access to the key is disabled. 4) location_id is not supported by Logging. 5) location_id violate OrgPolicy.

See Enabling CMEK for Log Router for more information.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSettings(UpdateSettingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSettings(Settings settings, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSettingsCallable()

CopyLogEntries

Copies a set of log entries from a log bucket to a Cloud Storage bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • copyLogEntriesAsync(CopyLogEntriesRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • copyLogEntriesOperationCallable()

  • copyLogEntriesCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ConfigSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ConfigSettings configSettings =
     ConfigSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ConfigClient configClient = ConfigClient.create(configSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ConfigSettings configSettings = ConfigSettings.newBuilder().setEndpoint(myEndpoint).build();
 ConfigClient configClient = ConfigClient.create(configSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

ConfigClient.ListBucketsFixedSizeCollection

ConfigClient.ListBucketsPage

ConfigClient.ListBucketsPagedResponse

ConfigClient.ListExclusionsFixedSizeCollection

ConfigClient.ListExclusionsPage

ConfigClient.ListExclusionsPagedResponse

ConfigClient.ListLinksFixedSizeCollection

ConfigClient.ListLinksPage

ConfigClient.ListLinksPagedResponse

ConfigClient.ListSinksFixedSizeCollection

ConfigClient.ListSinksPage

ConfigClient.ListSinksPagedResponse

ConfigClient.ListViewsFixedSizeCollection

ConfigClient.ListViewsPage

ConfigClient.ListViewsPagedResponse

ConfigSettings

Settings class to configure an instance of ConfigClient.

The default instance has everything set to sensible defaults:

  • The default service address (logging.googleapis.com) and default port (443) are used.
  • Credentials are acquired automatically through Application Default Credentials.
  • Retries are configured for idempotent methods but not for non-idempotent methods.

The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.

For example, to set the total timeout of getBucket to 30 seconds:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ConfigSettings.Builder configSettingsBuilder = ConfigSettings.newBuilder();
 configSettingsBuilder
     .getBucketSettings()
     .setRetrySettings(
         configSettingsBuilder
             .getBucketSettings()
             .getRetrySettings()
             .toBuilder()
             .setTotalTimeout(Duration.ofSeconds(30))
             .build());
 ConfigSettings configSettings = configSettingsBuilder.build();
 

ConfigSettings.Builder

Builder for ConfigSettings.

LoggingClient

Service Description: Service for ingesting and querying logs.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LoggingClient loggingClient = LoggingClient.create()) {
   LogName logName = LogName.ofProjectLogName("[PROJECT]", "[LOG]");
   loggingClient.deleteLog(logName);
 }
 

Note: close() needs to be called on the LoggingClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
MethodDescriptionMethod Variants

DeleteLog

Deletes all the log entries in a log for the _Default Log Bucket. The log reappears if it receives new entries. Log entries written shortly before the delete operation might not be deleted. Entries received after the delete operation with a timestamp before the operation will be deleted.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteLog(DeleteLogRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteLog(LogName logName)

  • deleteLog(String logName)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteLogCallable()

WriteLogEntries

Writes log entries to Logging. This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • writeLogEntries(WriteLogEntriesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • writeLogEntries(LogName logName, MonitoredResource resource, Map<String, String> labels, List<LogEntry> entries)

  • writeLogEntries(String logName, MonitoredResource resource, Map<String, String> labels, List<LogEntry> entries)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • writeLogEntriesCallable()

ListLogEntries

Lists log entries. Use this method to retrieve log entries that originated from a project/folder/organization/billing account. For ways to export log entries, see Exporting Logs.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLogEntries(ListLogEntriesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listLogEntries(List<String> resourceNames, String filter, String orderBy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLogEntriesPagedCallable()

  • listLogEntriesCallable()

ListMonitoredResourceDescriptors

Lists the descriptors for monitored resource types used by Logging.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listMonitoredResourceDescriptorsPagedCallable()

  • listMonitoredResourceDescriptorsCallable()

ListLogs

Lists the logs in projects, organizations, folders, or billing accounts. Only logs that have entries are listed.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLogs(ListLogsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listLogs(BillingAccountName parent)

  • listLogs(FolderName parent)

  • listLogs(OrganizationName parent)

  • listLogs(ProjectName parent)

  • listLogs(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLogsPagedCallable()

  • listLogsCallable()

TailLogEntries

Streaming read of log entries as they are ingested. Until the stream is terminated, it will continue reading logs.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • tailLogEntriesCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of LoggingSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LoggingSettings loggingSettings =
     LoggingSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 LoggingClient loggingClient = LoggingClient.create(loggingSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LoggingSettings loggingSettings = LoggingSettings.newBuilder().setEndpoint(myEndpoint).build();
 LoggingClient loggingClient = LoggingClient.create(loggingSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

LoggingClient.ListLogEntriesFixedSizeCollection

LoggingClient.ListLogEntriesPage

LoggingClient.ListLogEntriesPagedResponse

LoggingClient.ListLogsFixedSizeCollection

LoggingClient.ListLogsPage

LoggingClient.ListLogsPagedResponse

LoggingClient.ListMonitoredResourceDescriptorsFixedSizeCollection

LoggingClient.ListMonitoredResourceDescriptorsPage

LoggingClient.ListMonitoredResourceDescriptorsPagedResponse

LoggingSettings

Settings class to configure an instance of LoggingClient.

The default instance has everything set to sensible defaults:

  • The default service address (logging.googleapis.com) and default port (443) are used.
  • Credentials are acquired automatically through Application Default Credentials.
  • Retries are configured for idempotent methods but not for non-idempotent methods.

The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.

For example, to set the total timeout of deleteLog to 30 seconds:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LoggingSettings.Builder loggingSettingsBuilder = LoggingSettings.newBuilder();
 loggingSettingsBuilder
     .deleteLogSettings()
     .setRetrySettings(
         loggingSettingsBuilder
             .deleteLogSettings()
             .getRetrySettings()
             .toBuilder()
             .setTotalTimeout(Duration.ofSeconds(30))
             .build());
 LoggingSettings loggingSettings = loggingSettingsBuilder.build();
 

LoggingSettings.Builder

Builder for LoggingSettings.

MetricsClient

Service Description: Service for configuring logs-based metrics.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (MetricsClient metricsClient = MetricsClient.create()) {
   LogMetricName metricName = LogMetricName.of("[PROJECT]", "[METRIC]");
   LogMetric response = metricsClient.getLogMetric(metricName);
 }
 

Note: close() needs to be called on the MetricsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
MethodDescriptionMethod Variants

ListLogMetrics

Lists logs-based metrics.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listLogMetrics(ListLogMetricsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listLogMetrics(ProjectName parent)

  • listLogMetrics(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listLogMetricsPagedCallable()

  • listLogMetricsCallable()

GetLogMetric

Gets a logs-based metric.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getLogMetric(GetLogMetricRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getLogMetric(LogMetricName metricName)

  • getLogMetric(String metricName)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getLogMetricCallable()

CreateLogMetric

Creates a logs-based metric.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createLogMetric(CreateLogMetricRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createLogMetric(ProjectName parent, LogMetric metric)

  • createLogMetric(String parent, LogMetric metric)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createLogMetricCallable()

UpdateLogMetric

Creates or updates a logs-based metric.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateLogMetric(UpdateLogMetricRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateLogMetric(LogMetricName metricName, LogMetric metric)

  • updateLogMetric(String metricName, LogMetric metric)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateLogMetricCallable()

DeleteLogMetric

Deletes a logs-based metric.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteLogMetric(DeleteLogMetricRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteLogMetric(LogMetricName metricName)

  • deleteLogMetric(String metricName)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteLogMetricCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of MetricsSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 MetricsSettings metricsSettings =
     MetricsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 MetricsClient metricsClient = MetricsClient.create(metricsSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 MetricsSettings metricsSettings = MetricsSettings.newBuilder().setEndpoint(myEndpoint).build();
 MetricsClient metricsClient = MetricsClient.create(metricsSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

MetricsClient.ListLogMetricsFixedSizeCollection

MetricsClient.ListLogMetricsPage

MetricsClient.ListLogMetricsPagedResponse

MetricsSettings

Settings class to configure an instance of MetricsClient.

The default instance has everything set to sensible defaults:

  • The default service address (logging.googleapis.com) and default port (443) are used.
  • Credentials are acquired automatically through Application Default Credentials.
  • Retries are configured for idempotent methods but not for non-idempotent methods.

The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.

For example, to set the total timeout of getLogMetric to 30 seconds:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 MetricsSettings.Builder metricsSettingsBuilder = MetricsSettings.newBuilder();
 metricsSettingsBuilder
     .getLogMetricSettings()
     .setRetrySettings(
         metricsSettingsBuilder
             .getLogMetricSettings()
             .getRetrySettings()
             .toBuilder()
             .setTotalTimeout(Duration.ofSeconds(30))
             .build());
 MetricsSettings metricsSettings = metricsSettingsBuilder.build();
 

MetricsSettings.Builder

Builder for MetricsSettings.