Interface Logger


@ThreadSafe public interface Logger
A Logger is the entry point into a log pipeline.

Obtain a logRecordBuilder(), add properties using the setters, and emit it via LogRecordBuilder.emit().

The OpenTelemetry logs bridge API exists to enable bridging logs from other log frameworks (e.g. SLF4J, Log4j, JUL, Logback, etc) into OpenTelemetry and is NOT a replacement log API.

Since:
1.27.0
  • Method Details

    • isEnabled

      default boolean isEnabled(Severity severity, io.opentelemetry.context.Context context)
      Returns true if the logger is enabled for the given context and severity.

      This allows callers to avoid unnecessary compute when nothing is consuming the data. Because the response is subject to change over the application, callers should call this before each call to logRecordBuilder().

      Since:
      1.61.0
    • isEnabled

      default boolean isEnabled(Severity severity)
      Overload of isEnabled(Severity, Context) assuming Context.current().
      Since:
      1.61.0
    • logRecordBuilder

      LogRecordBuilder logRecordBuilder()
      Return a LogRecordBuilder to emit a log record.

      IMPORTANT: this should be used to write appenders to bridge logs from logging frameworks (e.g. SLF4J, Log4j, JUL, Logback, etc). It is NOT a replacement for an application logging framework, and should not be used by application developers.

      Build the log record using the LogRecordBuilder setters, and emit via LogRecordBuilder.emit().