See: Description
Interface | Description |
---|---|
Logging | |
LoggingEnhancer |
An enhancer for log entries.
|
LoggingFactory |
An interface for Logging factories.
|
Class | Description |
---|---|
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.
|
LogEntry |
A Stackdriver Logging log entry.
|
LogEntry.Builder |
A builder for
LogEntry objects. |
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.WriteOption |
Class for specifying options for writing log entries.
|
LoggingHandler |
A logging handler that outputs logs generated with
Logger to
Stackdriver Logging. |
LoggingLevel |
This class adds some additional Java logging levels for Stackdriver Logging.
|
LoggingOptions | |
LoggingOptions.Builder | |
LoggingOptions.DefaultLoggingFactory | |
LoggingOptions.DefaultLoggingRpcFactory | |
Metric |
Stackdriver Logging metrics describe logs-based metric.
|
Metric.Builder |
A builder for
Metric objects. |
MetricInfo |
Stackdriver 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 |
Stackdriver Logging sinks can be used to control the export of your logs.
|
Sink.Builder |
A builder for
Sink objects. |
SinkInfo |
Stackdriver 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.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. |
TraceLoggingEnhancer |
Enum | Description |
---|---|
Logging.SortingField |
Fields according to which log entries can be sorted.
|
Logging.SortingOrder |
Sorting orders available when listing log entries.
|
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 Stackdriver Logging sink.
|
SinkInfo.VersionFormat |
Available log entry formats.
|
Synchronicity |
Used to specify the behavior of write calls to the Stackdriver 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 Stackdriver Logging. The snippet installs a Stackdriver 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 © 2019 Google LLC. All rights reserved.