Interface LogRecordBuilder


public interface LogRecordBuilder
Used to construct and emit log records from a Logger.

Obtain a Logger.logRecordBuilder(), add properties using the setters, and emit the log record by calling emit().

Since:
1.27.0
  • Method Details

    • setTimestamp

      LogRecordBuilder setTimestamp(long timestamp, TimeUnit unit)
      Set the epoch timestamp, using the timestamp and unit.

      The timestamp is the time at which the log record occurred. If unset, it will be set to the current time when emit() is called.

    • setTimestamp

      LogRecordBuilder setTimestamp(Instant instant)
      Set the epoch timestamp, using the instant.

      The timestamp is the time at which the log record occurred. If unset, it will be set to the current time when emit() is called.

    • setObservedTimestamp

      LogRecordBuilder setObservedTimestamp(long timestamp, TimeUnit unit)
      Set the epoch observedTimestamp, using the timestamp and unit.

      The observedTimestamp is the time at which the log record was observed. If unset, it will be set to the timestamp. observedTimestamp may be different from timestamp if logs are being processed asynchronously (e.g. from a file or on a different thread).

    • setObservedTimestamp

      LogRecordBuilder setObservedTimestamp(Instant instant)
      Set the observedTimestamp, using the instant.

      The observedTimestamp is the time at which the log record was observed. If unset, it will be set to the timestamp. observedTimestamp may be different from timestamp if logs are being processed asynchronously (e.g. from a file or on a different thread).

    • setContext

      LogRecordBuilder setContext(io.opentelemetry.context.Context context)
      Set the context.
    • setSeverity

      LogRecordBuilder setSeverity(Severity severity)
      Set the severity.
    • setSeverityText

      LogRecordBuilder setSeverityText(String severityText)
      Set the severity text.
    • setBody

      LogRecordBuilder setBody(String body)
      Set the body string.
    • setAllAttributes

      default LogRecordBuilder setAllAttributes(Attributes attributes)
      Sets attributes. If the LogRecordBuilder previously contained a mapping for any of the keys, the old values are replaced by the specified values.
    • setAttribute

      <T> LogRecordBuilder setAttribute(AttributeKey<T> key, T value)
      Sets an attribute.
    • emit

      void emit()
      Emit the log record.