Spring Boot 如何在Java中禁止打开遥测记录器

yhuiod9q  于 2022-11-23  发布在  Spring
关注(0)|答案(2)|浏览(137)

我在Sping Boot java应用程序中使用Open Telemetry,并且对于每个请求,Open Telemetry代理都记录了我想要抑制的额外日志行。由于客户端尝试不断轮询Kafka服务器状态,因此日志太多。io.opentelemetry.exporter.logging: ERROR似乎没有任何效果。

[opentelemetry.auto.trace 2021-03-30 09:20:12:470 -0700] [http-nio-9090-exec-1] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'PSFPublishAPIController.publish' : 785a452cf9bc6f901374af3c24491fc3 c3b50425ffd5090f INTERNAL [tracer: io.opentelemetry.javaagent.spring-webmvc-3.1:1.0.1] AttributesMap{data={thread.name=http-nio-9090-exec-1, thread.id=44}, capacity=128, totalAddedValues=2}
[opentelemetry.auto.trace 2021-03-30 09:20:12:476 -0700] [http-nio-9090-exec-1] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - '/sidhpsf/v1/psfpublish' : 785a452cf9bc6f901374af3c24491fc3 a4a3c3581efd9a24 SERVER [tracer: io.opentelemetry.javaagent.tomcat-7.0:1.0.1] AttributesMap{data={http.user_agent=PostmanRuntime/7.26.5, http.flavor=1.1, http.status_code=200, net.peer.port=54971, http.client_ip=0:0:0:0:0:0:0:1, thread.name=http-nio-9090-exec-1, net.peer.ip=0:0:0:0:0:0:0:1, http.method=POST, thread.id=44, http.url=http://localhost:9090/sidhpsf/v1/psfpublish}, capacity=128, totalAddedValues=10}
[opentelemetry.auto.trace 2021-03-30 09:20:12:741 -0700] [kafka-producer-network-thread | producer-1] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'Xorg-Data-Sharing-Input-Topic send' : 785a452cf9bc6f901374af3c24491fc3 b1deb386583762f2 PRODUCER [tracer: io.opentelemetry.javaagent.kafka-clients-0.11:1.0.1] AttributesMap{data={messaging.destination_kind=topic, messaging.system=kafka, thread.name=http-nio-9090-exec-1, thread.id=44}, capacity=128, totalAddedValues=5}

yml中的日志记录配置:

logging:
  level:
    root: ERROR
    com.org: DEBUG
    org.springframework: INFO
    io.opentelemetry.exporter.logging: ERROR
  pattern:
    console: '%d{HH:mm:ss.SSS} [%t,%X{trace_id}-%X{span_id}-%X{trace_flags}] %highlight{%-5level} %c{2.} - %msg%n'

启动器命令:

java -javaagent:/Users/rshar248/Documents/Softwares/opentelemetry-javaagent-all.jar \
-Dotel.resource.attributes=service.name=psf-service \
-Dotel.traces.exporter=logging -Dotel.metrics.exporter=none \
-Dspring.profiles.active=local app.jar

任何建议如何抑制遥测内部日志行将是一个很大的帮助。

8ehkhllq

8ehkhllq1#

根据OpenTelemetry文档:
可以使用-Dotel.javaagent.enabled=false(或使用等效的环境变量OTEL_JAVAAGENT_ENABLED=false)禁用代理。

dluptydi

dluptydi2#

要更改OpenTelemetry JavaAgent的日志级别,可在命令行使用命令系统属性io.opentelemetry.javaagent.slf4j.simpleLogger.defaultLogLevel
例如,要完全禁用JavaAgent日志记录,可以将以下赋值添加到应用程序启动命令中:

-Dio.opentelemetry.javaagent.slf4j.simpleLogger.defaultLogLevel=off

相关问题