Package com.google.cloud.logging
Class LogEntry.Builder
java.lang.Object
com.google.cloud.logging.LogEntry.Builder
- Enclosing class:
- LogEntry
A builder for
LogEntry
objects.-
Method Summary
Modifier and TypeMethodDescriptionAdds a label to the log entry's labels.build()
Creates aLogEntry
object for this builder.Clears all the labels of the log entry.setDestination
(LogDestinationName destination) Sets the log path destination name type associated with the log entry.setHttpRequest
(HttpRequest httpRequest) Sets information about the HTTP request associated with this log entry, if applicable.setInsertId
(String insertId) Sets a unique ID for the log entry.Sets an optional set of user-defined (key, value) data that provides additional information about the log entry.setLogName
(String logName) Sets the name of the log to which this log entry belongs.setOperation
(Operation operation) Sets information about an operation associated with the log entry, if applicable.setPayload
(Payload<?> payload) Sets the payload for this log entry.setReceiveTimestamp
(long milliseconds) Deprecated.This method is no longer recommended to setup the receive time timestamp.setReceiveTimestamp
(Instant receiveTimestamp) Sets the time the log entry was received by Cloud Logging.setResource
(com.google.cloud.MonitoredResource resource) Sets the monitored resource associated with this log entry.setSeverity
(Severity severity) Sets the severity of the log entry.setSourceLocation
(SourceLocation sourceLocation) Sets the source code location information associated with the log entry if any.Sets the ID of the trace span associated with the log entry, if any.Sets the ID of the trace span associated with the log entry, if any.setTimestamp
(long milliseconds) Deprecated.This method is no longer recommended to setup the entry timestamp.setTimestamp
(Instant timestamp) Sets the time at which the event described by the log entry occurred.Sets the resource name of the trace associated with the log entry, if any.Sets the resource name of the trace associated with the log entry, if any.setTraceSampled
(boolean traceSampled) Sets the sampling decision of the trace span associated with the log entry.
-
Method Details
-
setLogName
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
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
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
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
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
Sets the severity of the log entry. If not set,Severity.DEFAULT
is used. -
setInsertId
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
Sets information about the HTTP request associated with this log entry, if applicable. -
setLabels
Sets an optional set of user-defined (key, value) data that provides additional information about the log entry. -
addLabel
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
Clears all the labels of the log entry. Labels are user-defined (key, value) data that provides additional information about the log entry. -
setOperation
Sets information about an operation associated with the log entry, if applicable. -
setTrace
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
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
Sets the ID of the trace span associated with the log entry, if any. -
setSpanId
Sets the ID of the trace span associated with the log entry, if any. -
setTraceSampled
Sets the sampling decision of the trace span associated with the log entry. -
setSourceLocation
Sets the source code location information associated with the log entry if any. -
setPayload
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:
-
setDestination
Sets the log path destination name type associated with the log entry. -
build
Creates aLogEntry
object for this builder.
-