Package com.google.cloud.logging
Class LogEntry.Builder
- java.lang.Object
-
- com.google.cloud.logging.LogEntry.Builder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LogEntry.Builder
addLabel(String key, String value)
Adds a label to the log entry's labels.LogEntry
build()
Creates aLogEntry
object for this builder.LogEntry.Builder
clearLabels()
Clears all the labels of the log entry.LogEntry.Builder
setDestination(LogDestinationName destination)
Sets the log path destination name type associated with the log entry.LogEntry.Builder
setHttpRequest(HttpRequest httpRequest)
Sets information about the HTTP request associated with this log entry, if applicable.LogEntry.Builder
setInsertId(String insertId)
Sets a unique ID for the log entry.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.LogEntry.Builder
setLogName(String logName)
Sets the name of the log to which this log entry belongs.LogEntry.Builder
setOperation(Operation operation)
Sets information about an operation associated with the log entry, if applicable.LogEntry.Builder
setPayload(Payload<?> payload)
Sets the payload for this log entry.LogEntry.Builder
setReceiveTimestamp(long milliseconds)
Deprecated.This method is no longer recommended to setup the receive time timestamp.LogEntry.Builder
setReceiveTimestamp(Instant receiveTimestamp)
Sets the time the log entry was received by Cloud Logging.LogEntry.Builder
setResource(com.google.cloud.MonitoredResource resource)
Sets the monitored resource associated with this log entry.LogEntry.Builder
setSeverity(Severity severity)
Sets the severity of the log entry.LogEntry.Builder
setSourceLocation(SourceLocation sourceLocation)
Sets the source code location information associated with the log entry if any.LogEntry.Builder
setSpanId(Object spanId)
Sets the ID of the trace span associated with the log entry, if any.LogEntry.Builder
setSpanId(String spanId)
Sets the ID of the trace span associated with the log entry, if any.LogEntry.Builder
setTimestamp(long milliseconds)
Deprecated.This method is no longer recommended to setup the entry timestamp.LogEntry.Builder
setTimestamp(Instant timestamp)
Sets the time at which the event described by the log entry occurred.LogEntry.Builder
setTrace(Object trace)
Sets the resource name of the trace associated with the log entry, if any.LogEntry.Builder
setTrace(String trace)
Sets the resource name of the trace associated with the log entry, if any.LogEntry.Builder
setTraceSampled(boolean traceSampled)
Sets the sampling decision of the trace span associated with the log entry.
-
-
-
Method Detail
-
setLogName
@CanIgnoreReturnValue 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
.
-
setResource
@CanIgnoreReturnValue public LogEntry.Builder setResource(com.google.cloud.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.
-
setTimestamp
@CanIgnoreReturnValue @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.
-
setTimestamp
@CanIgnoreReturnValue 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.
-
setReceiveTimestamp
@CanIgnoreReturnValue @Deprecated public LogEntry.Builder setReceiveTimestamp(long milliseconds)
Deprecated.This method is no longer recommended to setup the receive time timestamp.Use
setReceiveTimestamp(java.time.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.
-
setReceiveTimestamp
@CanIgnoreReturnValue 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.
-
setSeverity
@CanIgnoreReturnValue public LogEntry.Builder setSeverity(Severity severity)
Sets the severity of the log entry. If not set,Severity.DEFAULT
is used.
-
setInsertId
@CanIgnoreReturnValue 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.
-
setHttpRequest
@CanIgnoreReturnValue public LogEntry.Builder setHttpRequest(HttpRequest httpRequest)
Sets information about the HTTP request associated with this log entry, if applicable.
-
setLabels
@CanIgnoreReturnValue 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.
-
addLabel
@CanIgnoreReturnValue 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.
-
clearLabels
@CanIgnoreReturnValue 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.
-
setOperation
@CanIgnoreReturnValue public LogEntry.Builder setOperation(Operation operation)
Sets information about an operation associated with the log entry, if applicable.
-
setTrace
@CanIgnoreReturnValue 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`.
-
setTrace
@CanIgnoreReturnValue 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`.
-
setSpanId
@CanIgnoreReturnValue public LogEntry.Builder setSpanId(String spanId)
Sets the ID of the trace span associated with the log entry, if any.
-
setSpanId
@CanIgnoreReturnValue public LogEntry.Builder setSpanId(Object spanId)
Sets the ID of the trace span associated with the log entry, if any.
-
setTraceSampled
@CanIgnoreReturnValue public LogEntry.Builder setTraceSampled(boolean traceSampled)
Sets the sampling decision of the trace span associated with the log entry.
-
setSourceLocation
@CanIgnoreReturnValue public LogEntry.Builder setSourceLocation(SourceLocation sourceLocation)
Sets the source code location information associated with the log entry if any.
-
setPayload
@CanIgnoreReturnValue 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 (seePayload.StringPayload
), a JSON object (seePayload.JsonPayload
, or a protobuf object (seePayload.ProtoPayload
).- See Also:
- Log Entries and Logs
-
setDestination
@CanIgnoreReturnValue public LogEntry.Builder setDestination(LogDestinationName destination)
Sets the log path destination name type associated with the log entry.
-
build
public LogEntry build()
Creates aLogEntry
object for this builder.
-
-