public class LogEntry extends Object implements Serializable
Payload.StringPayload
), a JSON
object (see Payload.JsonPayload
, or a protobuf object (see Payload.ProtoPayload
).
Entries can also store additional information about the operation or the HTTP request that
generated the log (see getOperation()
and getHttpRequest()
,
respectively).Modifier and Type | Class and Description |
---|---|
static class |
LogEntry.Builder
A builder for
LogEntry objects. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
LogDestinationName |
getDestination()
Returns the log path destination name type associated with log entry.
|
HttpRequest |
getHttpRequest()
Returns information about the HTTP request associated with this log entry, if applicable.
|
String |
getInsertId()
Returns a unique ID for the log entry.
|
Instant |
getInstantReceiveTimestamp()
Returns the time the log entry was received by Cloud Logging, in milliseconds.
|
Instant |
getInstantTimestamp()
Returns the time at which the event described by the log entry occurred.
|
Map<String,String> |
getLabels()
Returns an optional set of user-defined (key, value) data that provides additional information
about the log entry.
|
String |
getLogName()
Returns the name of the log to which this log entry belongs.
|
Operation |
getOperation()
Returns information about an operation associated with the log entry, if applicable.
|
<T extends Payload<?>> |
getPayload()
Returns the payload for this log entry.
|
Long |
getReceiveTimestamp()
Deprecated.
This method is no longer recommended to get the received time timestamp.
Use |
com.google.cloud.MonitoredResource |
getResource()
Returns the monitored resource associated with this log entry.
|
Severity |
getSeverity()
Returns the severity of the log entry.
|
SourceLocation |
getSourceLocation()
Returns the source code location information associated with the log entry, if any.
|
String |
getSpanId()
Returns the ID of the trace span associated with the log entry, if any.
|
Long |
getTimestamp()
Deprecated.
This method is no longer recommended to get the entry timestamp.
Use |
String |
getTrace()
Returns the resource name of the trace associated with the log entry, if any.
|
boolean |
getTraceSampled()
Returns the sampling decision of the trace span associated with the log entry, or
false
if there is no trace span. |
int |
hashCode() |
static LogEntry.Builder |
newBuilder(Payload<?> payload)
Returns a builder for
LogEntry objects given the entry payload. |
static LogEntry |
of(Payload<?> payload)
Creates a
LogEntry object given the entry payload. |
static LogEntry |
of(String logName,
com.google.cloud.MonitoredResource resource,
Payload<?> payload)
Creates a
LogEntry object given the log name, the monitored resource and the entry
payload. |
LogEntry.Builder |
toBuilder()
Returns a
Builder for this log entry. |
String |
toString() |
String |
toStructuredJsonString()
Serializes the object to a one line JSON string in the simplified format that can be parsed by
the logging agents that run on Google Cloud resources.
|
public String getLogName()
[A-Za-z0-9]
; and punctuation characters: _-./
. The
forward-slash (/
) characters in the log name must be URL-encoded. Examples: syslog
, library.googleapis.com%2Fbook_log
.public com.google.cloud.MonitoredResource getResource()
@Deprecated public Long getTimestamp()
Use getInstantTimestamp()
instead.
public Instant getInstantTimestamp()
Instant
@Deprecated public Long getReceiveTimestamp()
Use getInstantReceiveTimestamp()
instead.
public Instant getInstantReceiveTimestamp()
Instant
public Severity getSeverity()
Severity.DEFAULT
is used.public String getInsertId()
public HttpRequest getHttpRequest()
public Map<String,String> getLabels()
public Operation getOperation()
public String getTrace()
public String getSpanId()
public boolean getTraceSampled()
false
if there is no trace span.public SourceLocation getSourceLocation()
public <T extends Payload<?>> T getPayload()
Payload.StringPayload
), a JSON object (see Payload.JsonPayload
, or a protobuf
object (see Payload.ProtoPayload
).public LogDestinationName getDestination()
public LogEntry.Builder toBuilder()
Builder
for this log entry.public String toStructuredJsonString()
public static LogEntry.Builder newBuilder(Payload<?> payload)
LogEntry
objects given the entry payload.Copyright © 2023 Google LLC. All rights reserved.