Skip to content

Commit 78aff64

Browse files
committed
reuse any configured logger
1 parent 723db24 commit 78aff64

File tree

1 file changed

+5
-4
lines changed
  • internal-logging/src/main/java/co/elastic/otel/logging

1 file changed

+5
-4
lines changed

internal-logging/src/main/java/co/elastic/otel/logging/AgentLog.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
3030
import io.opentelemetry.sdk.trace.export.SpanExporter;
3131
import java.util.Collection;
32+
import java.util.List;
3233
import java.util.concurrent.atomic.AtomicBoolean;
3334
import org.apache.logging.log4j.Level;
3435
import org.apache.logging.log4j.core.config.Configurator;
@@ -90,11 +91,11 @@ public static void addSpanLoggingIfRequired(
9091
// spans logging will be done by the explicitly configured logging exporter instance.
9192

9293
logPlainText = config.getBoolean(OTEL_JAVAAGENT_DEBUG, false);
93-
String exporterName = logPlainText ? "logging" : "otlp-logging";
9494

95-
boolean loggingExporterNotAlreadyConfigured =
96-
!config.getList("otel.traces.exporter", emptyList()).contains(exporterName);
97-
if (loggingExporterNotAlreadyConfigured) {
95+
List<String> configuredExporters = config.getList("otel.traces.exporter", emptyList());
96+
boolean loggingConfigured =
97+
configuredExporters.stream().anyMatch(e -> e.equals("logging") || e.equals("otlp-logging"));
98+
if (!loggingConfigured) {
9899
debugLogSpanExporter =
99100
new DebugLogSpanExporter(
100101
logPlainText ? LoggingSpanExporter.create() : OtlpJsonLoggingSpanExporter.create());

0 commit comments

Comments
 (0)