Package io.opentelemetry.sdk.logs
Class SdkLogger
java.lang.Object
io.opentelemetry.sdk.logs.SdkLogger
- All Implemented Interfaces:
ExtendedLogger
,Logger
SDK implementation of
Logger
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final InstrumentationScopeInfo
private final boolean
private final LoggerSharedState
private static final Logger
-
Constructor Summary
ConstructorsConstructorDescriptionSdkLogger
(LoggerSharedState loggerSharedState, InstrumentationScopeInfo instrumentationScopeInfo, LoggerConfig loggerConfig) -
Method Summary
Modifier and TypeMethodDescription(package private) InstrumentationScopeInfo
boolean
Returnstrue
if the logger is enabled.Return aLogRecordBuilder
to emit a log record.
-
Field Details
-
NOOP_LOGGER
-
instrumentationScopeInfo
-
loggerEnabled
private final boolean loggerEnabled
-
-
Constructor Details
-
Method Details
-
logRecordBuilder
Description copied from interface:Logger
Return aLogRecordBuilder
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 viaLogRecordBuilder.emit()
.- Specified by:
logRecordBuilder
in interfaceLogger
-
getInstrumentationScopeInfo
InstrumentationScopeInfo getInstrumentationScopeInfo() -
isEnabled
public boolean isEnabled()Description copied from interface:ExtendedLogger
Returnstrue
if 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:
isEnabled
in interfaceExtendedLogger
-