Skip to content

Make use of logback's MDC to add context to log statements #3234

Open

Description

@nscuro

Current Behavior

Dependency-Track performs many tasks asynchronously. Status updates, warnings, and errors are logged during task execution, however those logs lack context:

  • When BOM processing fails, it's unclear for which BOM, uploaded to what project
  • When VEX processing fails, it's unclear for which VEX, uploaded to what project
  • When repository metadata analysis fails, it's unclear for which component, and for what repository
  • etc.

Proposed Behavior

Logback offers a feature to add additional context to log statements via Mapped Diagnostic Context (MDC).

We should use that to attach context information, for example:

  • Project UUID, name, version
  • Component UUID, name, version
  • BOM / VEX format, spec version, serial number, version
  • etc.

wherever appropriate. When logging to JSON format, those context variables are represented as dedicated JSON fields and can thus be indexed by log aggregators (Elasticsearch, Splunk, ...).

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementp3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions