Interface LoggerProvider


@ThreadSafe public interface LoggerProvider
A registry for creating scoped Loggers. The name Provider is for consistency with other languages and it is NOT loaded using reflection.

The OpenTelemetry logging API exists to satisfy two use cases:

  1. Enable emitting structured events via Logger.eventBuilder(String). Requires assigning an event domain to the Logger.
  2. Enable the creation of log appenders, which bridge logs from other log frameworks (e.g. SLF4J, Log4j, JUL, Logback, etc) into OpenTelemetry via Logger.logRecordBuilder(). It is NOT a replacement log framework.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default Logger
    get(String instrumentationScopeName)
    Gets or creates a named Logger instance.
    loggerBuilder(String instrumentationScopeName)
    Creates a LoggerBuilder for a named Logger instance.
    Returns a no-op LoggerProvider which provides Loggers which do not record or emit.
  • Method Details

    • get

      default Logger get(String instrumentationScopeName)
      Gets or creates a named Logger instance.
      Parameters:
      instrumentationScopeName - A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.
      Returns:
      a Logger instance.
    • loggerBuilder

      LoggerBuilder loggerBuilder(String instrumentationScopeName)
      Creates a LoggerBuilder for a named Logger instance.
      Parameters:
      instrumentationScopeName - A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.
      Returns:
      a LoggerBuilder instance.
    • noop

      static LoggerProvider noop()
      Returns a no-op LoggerProvider which provides Loggers which do not record or emit.