Minimal setup for using otel logback appender with java agent #13635
-
I am using the OTEL logback appender in my project alongside the OTEL java agent. I have the following logback configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{MM/dd HH:mm:ss} %-5level %logger{1} - %msg%n%replace(%xException){'\n',' | '}%nopex</pattern>
</encoder>
<target>System.out</target>
</appender>
<appender name="OpenTelemetry" class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
<captureExperimentalAttributes>true</captureExperimentalAttributes>
<numLogsCapturedBeforeOtelInstall>500</numLogsCapturedBeforeOtelInstall>
</appender>
<logger name="com.whbettingengine.metrics.OtelSportsCatalogLogRecordPublisher" additivity="false">
<level value="INFO"/>
<appender-ref ref="OpenTelemetry"/>
</logger>
<root level="${LOG_LEVEL:-INFO}">
<appender-ref ref="CONSOLE"/>
</root>
</configuration> To make it such that not all logs are exported, I'm setting With this configuration, logs are not exported (I would expect the logs from Note: this discussion is similar, but I am following what's described in the answer and it is not working for me. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It turns out I needed to manually register the OpenTelemetryAppender.install(GlobalOpenTelemetry.get()) as part of configuring the application. |
Beta Was this translation helpful? Give feedback.
It turns out I needed to manually register the
GlobalOpenTelemetry
instance to the OTEL appender:as part of configuring the application.