See: Description
Interface | Description |
---|---|
ITimestampDefaultFilter |
Encapsulates implementation of default time filter.
|
Logging | |
LoggingEnhancer |
An enhancer for log entries.
|
LoggingFactory |
An interface for Logging factories.
|
ResourceTypeEnvironmentGetter |
Class | Description |
---|---|
Context |
Class to hold context attributes including information about
HttpRequest and tracing. |
Context.Builder |
A builder for
Context objects. |
ContextHandler |
Class provides a per-thread storage of the
Context instances. |
Exclusion |
Specifies a set of log entries that are not to be stored in Logging.
|
Exclusion.Builder |
A builder for
Exclusion objects. |
HttpRequest |
Objects of this class represent information about the (optional) HTTP request associated with a
log entry.
|
HttpRequest.Builder |
A builder for
HttpRequest objects. |
HttpRequest.RequestMethod |
The HTTP request method.
|
Instrumentation | |
LogDestinationName |
Class for specifying resource name of the log to which this log entry belongs (see 'logName'
parameter in https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry)
|
LogEntry |
A Cloud Logging log entry.
|
LogEntry.Builder |
A builder for
LogEntry objects. |
LogEntryIterator |
The class implements
Iterator interface over LogEntry by iterating through TailLogEntriesResponse streamed by BidiStream . |
LogEntryServerStream | |
Logging.EntryListOption |
Class for specifying options for listing log entries.
|
Logging.ListOption |
Class for specifying options for listing sinks, monitored resources and monitored resource
descriptors.
|
Logging.TailOption |
Class for specifying options for tailing log entries.
|
Logging.WriteOption |
Class for specifying options for writing log entries.
|
LoggingHandler |
A logging handler that outputs logs generated with
Logger to Cloud
Logging. |
LoggingLevel |
This class adds some additional Java logging levels for Cloud Logging.
|
LoggingOptions | |
LoggingOptions.Builder | |
LoggingOptions.DefaultLoggingFactory | |
LoggingOptions.DefaultLoggingRpcFactory | |
MetadataLoader | |
Metric |
Cloud Logging metrics describe logs-based metric.
|
Metric.Builder |
A builder for
Metric objects. |
MetricInfo |
Cloud Logging metrics describe logs-based metric.
|
MetricInfo.Builder |
A builder for
MetricInfo objects. |
MonitoredResourceUtil |
Monitored resource construction utilities to detect resource type and add labels.
|
Operation |
Additional information about a potentially long-running operation with which a log entry is
associated.
|
Operation.Builder |
A builder for
Operation objects. |
Payload<T> |
A base class for log entry payloads.
|
Payload.JsonPayload |
A log entry's JSON payload.
|
Payload.ProtoPayload |
A log entry payload as a protobuf object.
|
Payload.StringPayload |
A log entry payload as an UTF-8 string.
|
Sink |
Cloud Logging sinks can be used to control the export of your logs.
|
Sink.Builder |
A builder for
Sink objects. |
SinkInfo |
Cloud Logging sinks can be used to control the export of your logs.
|
SinkInfo.Builder |
A builder for
SinkInfo objects. |
SinkInfo.Destination | |
SinkInfo.Destination.BucketDestination |
Class for specifying a Google Cloud Storage bucket as destination for the sink.
|
SinkInfo.Destination.DatasetDestination |
Class for specifying a Google Cloud BigQuery dataset as destination for the sink.
|
SinkInfo.Destination.LoggingBucketDestination | |
SinkInfo.Destination.TopicDestination |
Class for specifying a Google Cloud BigQuery dataset as destination for the sink.
|
SourceLocation |
Additional information about the source code location that produced the log entry.
|
SourceLocation.Builder |
A builder for
SourceLocation objects. |
TimestampDefaultFilter | |
TraceLoggingEnhancer |
Enum | Description |
---|---|
LogDestinationName.DestinationType | |
Logging.SortingField |
Fields according to which log entries can be sorted.
|
Logging.SortingOrder |
Sorting orders available when listing log entries.
|
LoggingHandler.LogTarget |
Where to send logs.
|
MonitoredResourceUtil.Label | |
Payload.Type |
Type for a log entry payload.
|
Severity |
The severity of the event described in a log entry.
|
SinkInfo.Destination.Type |
Type of destination for Cloud Logging sink.
|
SinkInfo.VersionFormat |
Available log entry formats.
|
Synchronicity |
Used to specify the behavior of write calls to the Cloud Logging service.
|
Exception | Description |
---|---|
LoggingException |
Logging service exception.
|
Here's a simple usage example for using google-cloud from Compute Engine/App Engine Flexible. This example shows how to write and list log entries. For the complete source code see WriteAndListLogEntries.java.
LoggingOptions options = LoggingOptions.getDefaultInstance();
try(Logging logging = options.getService()) {
LogEntry firstEntry = LogEntry.newBuilder(StringPayload.of("message"))
.setLogName("test-log")
.setResource(MonitoredResource.builder("global")
.addLabel("project_id", options.getProjectId())
.build())
.build();
logging.write(Collections.singleton(firstEntry));
Page<LogEntry> entries = logging.listLogEntries(
EntryListOption.filter("logName=projects/" + options.getProjectId() + "/logs/test-log"));
Iterator<LogEntry> entryIterator = entries.iterateAll();
while (entryIterator.hasNext()) {
System.out.println(entryIterator.next());
}
}
This second example shows how to use a Logger
to write log entries
to Cloud Logging. The snippet installs a Cloud Logging handler using LoggingHandler.addHandler(Logger, LoggingHandler)
. Notice that this could also be done through
the logging.properties
file, adding the following line:
com.google.cloud.examples.logging.snippets.AddLoggingHandler.handlers=com.google.cloud.logging.LoggingHandler
For the complete source code see
AddLoggingHandler.java.
Logger logger = Logger.getLogger(AddLoggingHandler.class.getName());
LoggingHandler.addHandler(logger, new LoggingHandler());
logger.warning("test warning");
Copyright © 2023 Google LLC. All rights reserved.