Skip to content

feat: structured JSON logging for production log aggregation#380

Merged
Oluwaseyi89 merged 11 commits into
NFTopia-Foundation:mainfrom
emarc99:feat/structured-prod-JSON-logging
Jul 9, 2026
Merged

feat: structured JSON logging for production log aggregation#380
Oluwaseyi89 merged 11 commits into
NFTopia-Foundation:mainfrom
emarc99:feat/structured-prod-JSON-logging

Conversation

@emarc99

@emarc99 emarc99 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR configures structured JSON logging for production log aggregation across both the NestJS REST API and the GraphQL gateway, replacing plain text logs with structured JSON. It also implements correlation ID tracing, request/response logging, and log redaction.

Key Changes

  • Shared Logger Configuration (logger.config.ts):
    • Output structured JSON in production; pino-pretty in development.
    • Configurable log level (LOG_LEVEL) and log sampling (LOG_SAMPLE_RATE).
    • Structured fields (service: 'nftopia-backend', environment, timestamp in ISO format).
    • Redacts sensitive data (password, token, authorization, cookie, secret, key, apiKey).
    • Truncates error stack traces to 10 lines and reduces verbosity for /health and /metrics endpoints.
  • Correlation ID Propagation:
    • CorrelationIdMiddleware: Extracts or generates x-correlation-id and sets it on the request and response headers.
    • CorrelationIdInterceptor: Global interceptor ensuring correlation ID propagation in both HTTP/REST and GraphQL response headers.
  • Service Integrations:
    • Configured AppModule and GraphqlGatewayModule to use the shared logger and middleware.
    • Unified the GraphQL gateway to use PinoLogger instead of NestLogger.
  • Fixes & Dependencies:
    • Added express as a direct dependency in package.json to resolve strict pnpm module resolution.
    • Imported AuditModule in AdminModule to fix a dependency resolution crash (UnknownDependenciesException for AuditService) introduced in the recent main branch pull.

Verification

  • A. Production Mode (Structured JSON Logs)
image
  • B. Development Mode (Pretty-Printed Logs)
image

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@emarc99 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@emarc99 emarc99 marked this pull request as draft July 1, 2026 00:37
@emarc99 emarc99 marked this pull request as ready for review July 9, 2026 09:05
@emarc99

emarc99 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@Oluwaseyi89

@Oluwaseyi89 Oluwaseyi89 merged commit b84dee5 into NFTopia-Foundation:main Jul 9, 2026
1 check passed
@Oluwaseyi89

Copy link
Copy Markdown
Contributor

@emarc99 I will advice you to go open a general ticket to claim your points as points were not automatically assigned.

@emarc99

emarc99 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

As that seems to be the case, I will open a ticket. Thanks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure structured JSON logging for production log aggregation

2 participants