Interface LogRecordBuilder
Logger.
Obtain a Logger.logRecordBuilder(), add properties using the setters, and emit the log
record by calling emit().
- Since:
- 1.27.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidemit()Emit the log record.default LogRecordBuildersetAllAttributes(Attributes attributes) Sets attributes.<T> LogRecordBuildersetAttribute(AttributeKey<T> key, T value) Sets an attribute on theLogRecord.default LogRecordBuildersetAttribute(String key, boolean value) Sets a Boolean attribute on theLogRecord.default LogRecordBuildersetAttribute(String key, double value) Sets a Double attribute on theLogRecord.default LogRecordBuildersetAttribute(String key, int value) Sets an Integer attribute on theLogRecord.default LogRecordBuildersetAttribute(String key, long value) Sets a Long attribute on theLogRecord.default LogRecordBuildersetAttribute(String key, String value) Sets a String attribute on theLogRecord.default LogRecordBuilderSet the bodyValue.Set the body string.setContext(io.opentelemetry.context.Context context) Set the context.default LogRecordBuildersetEventName(String eventName) Sets the event name, which identifies the class / type of the Event.setObservedTimestamp(long timestamp, TimeUnit unit) Set the epochobservedTimestamp, using the timestamp and unit.setObservedTimestamp(Instant instant) Set theobservedTimestamp, using the instant.setSeverity(Severity severity) Set the severity.setSeverityText(String severityText) Set the severity text.setTimestamp(long timestamp, TimeUnit unit) Set the epochtimestamp, using the timestamp and unit.setTimestamp(Instant instant) Set the epochtimestamp, using the instant.
-
Method Details
-
setTimestamp
Set the epochtimestamp, using the timestamp and unit.The
timestampis the time at which the log record occurred. If unset, it will be set to the current time whenemit()is called. -
setTimestamp
Set the epochtimestamp, using the instant.The
timestampis the time at which the log record occurred. If unset, it will be set to the current time whenemit()is called. -
setObservedTimestamp
Set the epochobservedTimestamp, using the timestamp and unit.The
observedTimestampis the time at which the log record was observed. If unset, it will be set to thetimestamp.observedTimestampmay be different fromtimestampif logs are being processed asynchronously (e.g. from a file or on a different thread). -
setObservedTimestamp
Set theobservedTimestamp, using the instant.The
observedTimestampis the time at which the log record was observed. If unset, it will be set to thetimestamp.observedTimestampmay be different fromtimestampif logs are being processed asynchronously (e.g. from a file or on a different thread). -
setContext
Set the context. -
setSeverity
Set the severity. -
setSeverityText
Set the severity text. -
setBody
Set the body string.Shorthand for calling
setBody(Value)withValue.of(String). -
setBody
Set the bodyValue.- Since:
- 1.42.0
-
setAllAttributes
Sets attributes. If theLogRecordBuilderpreviously contained a mapping for any of the keys, the old values are replaced by the specified values. -
setAttribute
Sets an attribute on theLogRecord. If theLogRecordpreviously contained a mapping for the key, the old value is replaced by the specified value.Note: Providing a null value is a no-op and will not remove previously set values.
- Parameters:
key- the key for this attribute.value- the value for this attribute.- Returns:
- this.
-
setAttribute
Sets a String attribute on theLogRecord. If theLogRecordpreviously contained a mapping for the key, the old value is replaced by the specified value.Note: Providing a null value is a no-op and will not remove previously set values.
Note: It is strongly recommended to use
setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.- Parameters:
key- the key for this attribute.value- the value for this attribute.- Returns:
- this.
- Since:
- 1.48.0
-
setAttribute
Sets a Long attribute on theLogRecord. If theLogRecordpreviously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.- Parameters:
key- the key for this attribute.value- the value for this attribute.- Returns:
- this.
- Since:
- 1.48.0
-
setAttribute
Sets a Double attribute on theLogRecord. If theLogRecordpreviously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.- Parameters:
key- the key for this attribute.value- the value for this attribute.- Returns:
- this.
- Since:
- 1.48.0
-
setAttribute
Sets a Boolean attribute on theLogRecord. If theLogRecordpreviously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.- Parameters:
key- the key for this attribute.value- the value for this attribute.- Returns:
- this.
- Since:
- 1.48.0
-
setAttribute
Sets an Integer attribute on theLogRecord. If theLogRecordpreviously contained a mapping for the key, the old value is replaced by the specified value.Note: It is strongly recommended to use
setAttribute(AttributeKey, Object), and pre-allocate your keys, if possible.- Parameters:
key- the key for this attribute.value- the value for this attribute.- Returns:
- this.
- Since:
- 1.48.0
-
setEventName
Sets the event name, which identifies the class / type of the Event.This name should uniquely identify the event structure (both attributes and body). A log record with a non-empty event name is an Event.
- Since:
- 1.50.0
-
emit
void emit()Emit the log record.
-