open-telemetry/opentelemetry-java-instrumentation

Add support for `logback-access` or `logback-core` library

railsharipov opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

Request logs are not exported when instrumenting DropWizard application. DropWizard uses logback-access library for request logging which is independent of logback-classic.

I am running Dropwizard app with OTel Contrib Java agent. I am running agent with default config, I have otlp log export enabled. I do see logs from application loggers (logback) but no server request logs.

Please see this discussion: #12588

Describe the solution you'd like

Add support for exporting request logs from DropWizard application.

Describe alternatives you've considered

I have tried using classic request logging: https://www.dropwizard.io/en/release-2.1.x/manual/configuration.html#classic-request-log

The classic request log uses the logback-classic library for processing request logs. It produces logs only in the standard NCSA common log format, but allows to use an extended set of appenders.

Dropwizard HTTP server config I have tried:

server:
  requestLog:
    type: classic
    timeZone: UTC
    appenders:
      - type: console

But request logs are still not getting exported.

Additional context

Here is my Dropwizard HTTP server config:

server:
  type: simple
  ...
  gzip:
    bufferSize: 8KiB
    enabled: true
    minimumEntitySize: 128B
    deflateCompressionLevel: 9
  requestLog:
    appenders:
      - type: console

Here is my Dropwizard logging config:

logging:
  level: INFO
  loggers:
    ...
  appenders:
    - type: console
      threshold: TRACE
      timeZone: "UTC"
      logFormat: ...

Here is the docker image I use to run app:

FROM amzn-corretto:17-alpine
...
ENV OTEL_LOG_LEVEL=error
ENV OTEL_JAVAAGENT_LOGGING=simple

ENV OTEL_LOGS_EXPORTER=otlp
ENV OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://otlp.example.com/v1/logs
ENV OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf

ENV OTEL_SERVICE_NAME=example

CMD exec java \
    -javaagent:opentelemetry-javaagent.jar \
    -jar /opt/example/example-shadow.jar server /etc/example/config.yml

DropWizard version:

dropwizardVersion = "2.1.0"