Skip to content

Structured JSON Logging #184

@mftee

Description

@mftee

Replace the current plain-text tracing output with structured JSON logs. Structured logs are machine-readable and integrate with log aggregation systems like Datadog, Loki, and Elasticsearch.

Requirements:

  • Replace tracing_subscriber::fmt() in main.rs with a JSON formatter using tracing-subscriber with the json feature
  • Every log entry must include:
    • timestamp (ISO 8601)
    • level (INFO, WARN, ERROR, DEBUG)
    • message
    • service (always "stellar-doc-verifier")
    • target (module path)
  • Add request-scoped context to logs using tracing::Span so that all logs within a request include:
    • request_id (UUID generated per request via middleware)
    • method (HTTP method)
    • path (request path)
  • Create an Axum middleware layer RequestTracingLayer that creates a span per request and injects request_id
  • Log level must be configurable via LOG_LEVEL env var (default: info)

Acceptance Criteria:

  • Every log line is valid JSON parseable by serde_json
  • Request logs include request_id field
  • LOG_LEVEL=debug enables debug output
  • Unit test parses a sample log line and asserts required fields are present

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions