Class LogEntry.Builder (3.16.2)

public static class LogEntry.Builder

A builder for LogEntry objects.

Inheritance

Object > LogEntry.Builder

Methods

addLabel(String key, String value)

public LogEntry.Builder addLabel(String key, String value)

Adds a label to the log entry's labels. Labels are user-defined (key, value) data that provides additional information about the log entry.

Parameters
NameDescription
keyString
valueString
Returns
TypeDescription
LogEntry.Builder

build()

public LogEntry build()

Creates a LogEntry object for this builder.

Returns
TypeDescription
LogEntry

clearLabels()

public LogEntry.Builder clearLabels()

Clears all the labels of the log entry. Labels are user-defined (key, value) data that provides additional information about the log entry.

Returns
TypeDescription
LogEntry.Builder

setDestination(LogDestinationName destination)

public LogEntry.Builder setDestination(LogDestinationName destination)

Sets the log path destination name type associated with the log entry.

Parameter
NameDescription
destinationLogDestinationName
Returns
TypeDescription
LogEntry.Builder

setHttpRequest(HttpRequest httpRequest)

public LogEntry.Builder setHttpRequest(HttpRequest httpRequest)

Sets information about the HTTP request associated with this log entry, if applicable.

Parameter
NameDescription
httpRequestHttpRequest
Returns
TypeDescription
LogEntry.Builder

setInsertId(String insertId)

public LogEntry.Builder setInsertId(String insertId)

Sets a unique ID for the log entry. If you provide this field, the Logging service considers other log entries in the same log with the same ID as duplicates which can be removed. If omitted, the Logging service will generate a unique ID for this log entry.

Parameter
NameDescription
insertIdString
Returns
TypeDescription
LogEntry.Builder

setLabels(Map<String,String> labels)

public LogEntry.Builder setLabels(Map<String,String> labels)

Sets an optional set of user-defined (key, value) data that provides additional information about the log entry.

Parameter
NameDescription
labelsMap<String,String>
Returns
TypeDescription
LogEntry.Builder

setLogName(String logName)

public LogEntry.Builder setLogName(String logName)

Sets 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.

Parameter
NameDescription
logNameString
Returns
TypeDescription
LogEntry.Builder

setOperation(Operation operation)

public LogEntry.Builder setOperation(Operation operation)

Sets information about an operation associated with the log entry, if applicable.

Parameter
NameDescription
operationOperation
Returns
TypeDescription
LogEntry.Builder

setPayload(Payload<?> payload)

public LogEntry.Builder setPayload(Payload<?> payload)

Sets the payload for this log entry. The log entry payload can be provided as an UTF-8 string (see Payload.StringPayload), a JSON object (see Payload.JsonPayload, or a protobuf object (see Payload.ProtoPayload). See Also: Log Entries and Logs

Parameter
NameDescription
payloadPayload<?>
Returns
TypeDescription
LogEntry.Builder

setReceiveTimestamp(Instant receiveTimestamp)

public LogEntry.Builder setReceiveTimestamp(Instant receiveTimestamp)

Sets the time the log entry was received by Cloud Logging. If omitted, the Logging service will set the time at which the log entry is received.

Parameter
NameDescription
receiveTimestampInstant
Returns
TypeDescription
LogEntry.Builder

setReceiveTimestamp(long milliseconds) (deprecated)

public LogEntry.Builder setReceiveTimestamp(long milliseconds)

Deprecated. This method is no longer recommended to setup the receive time timestamp.

Use setReceiveTimestamp(Instant) instead.

Sets the time the log entry was received by Cloud Logging, in milliseconds. If omitted, the Logging service will set the time at which the log entry is received.

Parameter
NameDescription
millisecondslong
Returns
TypeDescription
LogEntry.Builder

setResource(MonitoredResource resource)

public LogEntry.Builder setResource(MonitoredResource resource)

Sets 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.

Parameter
NameDescription
resourcecom.google.cloud.MonitoredResource
Returns
TypeDescription
LogEntry.Builder

setSeverity(Severity severity)

public LogEntry.Builder setSeverity(Severity severity)

Sets the severity of the log entry. If not set, Severity#DEFAULT is used.

Parameter
NameDescription
severitySeverity
Returns
TypeDescription
LogEntry.Builder

setSourceLocation(SourceLocation sourceLocation)

public LogEntry.Builder setSourceLocation(SourceLocation sourceLocation)

Sets the source code location information associated with the log entry if any.

Parameter
NameDescription
sourceLocationSourceLocation
Returns
TypeDescription
LogEntry.Builder

setSpanId(Object spanId)

public LogEntry.Builder setSpanId(Object spanId)

Sets the ID of the trace span associated with the log entry, if any.

Parameter
NameDescription
spanIdObject
Returns
TypeDescription
LogEntry.Builder

setSpanId(String spanId)

public LogEntry.Builder setSpanId(String spanId)

Sets the ID of the trace span associated with the log entry, if any.

Parameter
NameDescription
spanIdString
Returns
TypeDescription
LogEntry.Builder

setTimestamp(Instant timestamp)

public LogEntry.Builder setTimestamp(Instant timestamp)

Sets the time at which the event described by the log entry occurred. If omitted, the Logging service will use the time at which the log entry is received.

Parameter
NameDescription
timestampInstant
Returns
TypeDescription
LogEntry.Builder

setTimestamp(long milliseconds) (deprecated)

public LogEntry.Builder setTimestamp(long milliseconds)

Deprecated. This method is no longer recommended to setup the entry timestamp.

Use #setTimestamp(Instant) instead.

Sets the time at which the event described by the log entry occurred, in milliseconds. If omitted, the Logging service will use the time at which the log entry is received.

Parameter
NameDescription
millisecondslong
Returns
TypeDescription
LogEntry.Builder

setTrace(Object trace)

public LogEntry.Builder setTrace(Object trace)

Sets 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.

Parameter
NameDescription
traceObject
Returns
TypeDescription
LogEntry.Builder

setTrace(String trace)

public LogEntry.Builder setTrace(String trace)

Sets 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.

Parameter
NameDescription
traceString
Returns
TypeDescription
LogEntry.Builder

setTraceSampled(boolean traceSampled)

public LogEntry.Builder setTraceSampled(boolean traceSampled)

Sets the sampling decision of the trace span associated with the log entry.

Parameter
NameDescription
traceSampledboolean
Returns
TypeDescription
LogEntry.Builder