Skip to content

[FEATURE] Add structured JSON logging with correlation IDs for TransactionMs #8

Description

@abengl

Description
Replace default Spring Boot logging with structured JSON output and propagate a correlation ID through the full request chain so a single transfer can be traced across TransactionMs, AccountMs, and CustomerMs in log output.

Tasks

  • Add logback-spring.xml to each microservice (TransactionMs, AccountMs, CustomerMs) configured to output structured JSON using logstash-logback-encoder
  • Add a CorrelationIdFilter (WebFilter for WebFlux, OncePerRequestFilter for MVC) that reads X-Correlation-ID from the incoming request header or generates a UUID if absent
  • Propagate the correlation ID to MDC so it appears in every log line for that request
  • For outgoing WebClient calls (TransactionMs → AccountMs, CustomerMs → AccountMs), forward the X-Correlation-ID header in the request
  • Replace all System.out.println or unstructured log calls with SLF4J structured log statements with meaningful context fields (accountId, customerId, transactionId where relevant)
  • Validate that a single POST /api/v1/transactions/transfer produces log lines in TransactionMs and AccountMs sharing the same correlationId

Acceptance Criteria

  • All log output is valid JSON in the microservice
  • A transfer request produces log entries in TransactionMs and AccountMs with the same correlationId value
  • If the caller provides X-Correlation-ID: abc123, that value appears in all downstream log lines
  • If no header is provided, a UUID is generated and propagated
  • Log lines include at minimum: timestamp, level, service, correlationId, message

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions