Skip to content

MDC tag information not added to logs. #4783

@rodolfoBee

Description

@rodolfoBee

Integration

sentry

Java Version

11

Version

8.23.0

Steps to Reproduce

  1. Setup logs in a SpringBoot app or other java framework
  2. Add MDC tags
  3. Send errors and logs to Sentry
 Logger logger = LoggerFactory.getLogger("demo");
        MDC.put("MDCTag","MDCvalue");
        
        logger.info("MDC info log");
        logger.error("MDC error log");
        
        System.out.println(Sentry.isEnabled());
        try {
            System.out.println("throwing spring boot error.");
            throw new Exception("MDC tags test error");
        } catch (Exception e) {
            System.out.println(Sentry.captureException(e));
        }

SDK configuration:

sentry.dsn=...
sentry.traces-sample-rate=1.0

sentry.debug=true
sentry.logs.enabled=true

sentry.logging.minimumLevel=INFO
sentry.contextTags=MDCTag

Expected Result

MDC tag information is added to both logs and errors. Ideally, as tags so the information can be used to search events in Sentry.

Actual Result

MDC tags are currently only added as additional context to error event.
Error with MDC context

Logs without MDC context

[edit: fixing acronyms]

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions