Interface Logger
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 Summary
Modifier and TypeMethodDescriptiondefault booleanOverload ofisEnabled(Severity, Context)assumingContext.current().default booleanReturnstrueif the logger is enabled for the givencontextandseverity.Return aLogRecordBuilderto emit a log record.
-
Method Details
-
isEnabled
Returnstrueif the logger is enabled for the givencontextandseverity.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
Overload ofisEnabled(Severity, Context)assumingContext.current().- Since:
- 1.61.0
-
logRecordBuilder
LogRecordBuilder logRecordBuilder()Return 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().
-