Package io.opentelemetry.sdk.logs
Class SdkLogger
- java.lang.Object
-
- io.opentelemetry.sdk.logs.SdkLogger
-
- All Implemented Interfaces:
ExtendedLogger,Logger
final class SdkLogger extends java.lang.Object implements ExtendedLogger
SDK implementation ofLogger.
-
-
Field Summary
Fields Modifier and Type Field Description private InstrumentationScopeInfoinstrumentationScopeInfoprivate booleanloggerEnabledprivate LoggerSharedStateloggerSharedStateprivate static LoggerNOOP_LOGGER
-
Constructor Summary
Constructors Constructor Description SdkLogger(LoggerSharedState loggerSharedState, InstrumentationScopeInfo instrumentationScopeInfo, LoggerConfig loggerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) InstrumentationScopeInfogetInstrumentationScopeInfo()booleanisEnabled()Returnstrueif the logger is enabled.LogRecordBuilderlogRecordBuilder()Return aLogRecordBuilderto emit a log record.
-
-
-
Field Detail
-
NOOP_LOGGER
private static final Logger NOOP_LOGGER
-
loggerSharedState
private final LoggerSharedState loggerSharedState
-
instrumentationScopeInfo
private final InstrumentationScopeInfo instrumentationScopeInfo
-
loggerEnabled
private final boolean loggerEnabled
-
-
Constructor Detail
-
SdkLogger
SdkLogger(LoggerSharedState loggerSharedState, InstrumentationScopeInfo instrumentationScopeInfo, LoggerConfig loggerConfig)
-
-
Method Detail
-
logRecordBuilder
public LogRecordBuilder logRecordBuilder()
Description copied from interface:LoggerReturn aLogRecordBuilderto 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
LogRecordBuildersetters, and emit viaLogRecordBuilder.emit().- Specified by:
logRecordBuilderin interfaceLogger
-
getInstrumentationScopeInfo
InstrumentationScopeInfo getInstrumentationScopeInfo()
-
isEnabled
public boolean isEnabled()
Description copied from interface:ExtendedLoggerReturnstrueif the logger is enabled.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
Logger.logRecordBuilder().- Specified by:
isEnabledin interfaceExtendedLogger
-
-