public class LogEntry implements Serializable
A Cloud Logging log entry. All log entries are represented via objects of this class. Log entries can have different type of payloads: an UTF-8 string (see 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 LogEntry#getOperation() and LogEntry#getHttpRequest(), respectively).
Implements
SerializableMethods
<T>getPayload()
public T <T>getPayload()
Returns the payload for this log entry. The log entry payload can be an UTF-8 string (see Payload.StringPayload), a JSON object (see Payload.JsonPayload, or a protobuf object (see Payload.ProtoPayload).
Type | Description |
T |
equals(Object obj)
public boolean equals(Object obj)
Name | Description |
obj | Object |
Type | Description |
boolean |
getDestination()
public LogDestinationName getDestination()
Returns the log path destination name type associated with log entry. By default, project name based destination is used.
Type | Description |
LogDestinationName |
getHttpRequest()
public HttpRequest getHttpRequest()
Returns information about the HTTP request associated with this log entry, if applicable.
Type | Description |
HttpRequest |
getInsertId()
public String getInsertId()
Returns a unique ID for the log entry. The Logging service considers other log entries in the same log with the same ID as duplicates which can be removed.
Type | Description |
String |
getInstantReceiveTimestamp()
public Instant getInstantReceiveTimestamp()
Returns the time the log entry was received by Cloud Logging, in milliseconds.
Type | Description |
Instant | timestamp as Instant |
getInstantTimestamp()
public Instant getInstantTimestamp()
Returns the time at which the event described by the log entry occurred.
Type | Description |
Instant | timestamp as Instant |
getLabels()
public Map<String,String> getLabels()
Returns an optional set of user-defined (key, value) data that provides additional information about the log entry.
Type | Description |
Map<String,String> |
getLogName()
public String getLogName()
Returns the name of the log to which this log entry belongs. The log name must be less than 512
characters long and can only include the following characters: upper and lower case
alphanumeric characters: [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
.
Type | Description |
String |
getOperation()
public Operation getOperation()
Returns information about an operation associated with the log entry, if applicable.
Type | Description |
Operation |
getReceiveTimestamp() (deprecated)
public Long getReceiveTimestamp()
(deprecated) This method is no longer recommended to get the received time timestamp.
Use getInstantReceiveTimestamp() instead.
Returns the time the log entry was received by Cloud Logging, in milliseconds.Type | Description |
Long | timestamp in milliseconds |
getResource()
public MonitoredResource getResource()
Returns the monitored resource associated with this log entry. Example: a log entry that reports a database error would be associated with the monitored resource designating the particular database that reported the error.
Type | Description |
com.google.cloud.MonitoredResource |
getSeverity()
public Severity getSeverity()
Returns the severity of the log entry. If not set, Severity#DEFAULT is used.
Type | Description |
Severity |
getSourceLocation()
public SourceLocation getSourceLocation()
Returns the source code location information associated with the log entry, if any.
Type | Description |
SourceLocation |
getSpanId()
public String getSpanId()
Returns the ID of the trace span associated with the log entry, if any.
Type | Description |
String |
getTimestamp() (deprecated)
public Long getTimestamp()
(deprecated) This method is no longer recommended to get the entry timestamp.
Use getInstantTimestamp() instead.
Returns the time at which the event described by the log entry occurred, in milliseconds.Type | Description |
Long | timestamp in milliseconds |
getTrace()
public String getTrace()
Returns the resource name of the trace associated with the log entry, if any. If it contains a
relative resource name, the name is assumed to be relative to //tracing.googleapis.com
.
Type | Description |
String |
getTraceSampled()
public boolean getTraceSampled()
Returns the sampling decision of the trace span associated with the log entry, or false
if there is no trace span.
Type | Description |
boolean |
hashCode()
public int hashCode()
Type | Description |
int |
newBuilder(Payload<?> payload)
public static LogEntry.Builder newBuilder(Payload<?> payload)
Returns a builder for LogEntry
objects given the entry payload.
Name | Description |
payload | Payload<?> |
Type | Description |
LogEntry.Builder |
of(Payload<?> payload)
public static LogEntry of(Payload<?> payload)
Creates a LogEntry
object given the entry payload.
Name | Description |
payload | Payload<?> |
Type | Description |
LogEntry |
of(String logName, MonitoredResource resource, Payload<?> payload)
public static LogEntry of(String logName, MonitoredResource resource, Payload<?> payload)
Creates a LogEntry
object given the log name, the monitored resource and the entry
payload.
Name | Description |
logName | String |
resource | com.google.cloud.MonitoredResource |
payload | Payload<?> |
Type | Description |
LogEntry |
toBuilder()
public LogEntry.Builder toBuilder()
Returns a Builder
for this log entry.
Type | Description |
LogEntry.Builder |
toString()
public String toString()
Type | Description |
String |