Skip to content

Integrate Structured Logging #123

@Olowodarey

Description

@Olowodarey

The default NestJS console logger is not suitable for production. We want to implement structured JSON logging using nestjs-pino to make searching and parsing logs in tools like Datadog or ELK much easier.

Acceptance Criteria

  • Install nestjs-pino and pino-http.
  • Configure LoggerModule globally in AppModule.
  • Replace the default NestJS logger in main.ts with the Pino logger.
  • Ensure that local development logs are pretty-printed, while production logs are in raw JSON format.

Technical Details/Guide

Install dependencies: npm i nestjs-pino pino-http and npm i -D pino-pretty.
Configure in main.ts:

import { Logger } from 'nestjs-pino';
const app = await NestFactory.create(AppModule, { bufferLogs: true });
app.useLogger(app.get(Logger));

Useful Resources

Metadata

Metadata

Labels

BackendbackendStellar WaveIssues in the Stellar wave program

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions