Nestjs Context Logger

screenshot of Nestjs Context Logger
express
nestjs

Contextual Logger for NestJS

Overview

The nestjs-context-logger is an indispensable tool for developers working within the NestJS framework. It enhances the logging experience by adding context-rich information to your logs. This can significantly reduce the time spent debugging production issues, allowing for a more productive development process. With the increasing complexity of applications, having detailed logs can mean the difference between a swift resolution and prolonged downtime.

What sets this logger apart is its seamless integration with existing systems. There is no need for extensive code changes, meaning developers can enjoy the benefits of enriched logging without disruption. It's designed to be performant, built on the robust Pino logger, ensuring that it meets the demands of high-load applications.

Features

  • Developer Experience: Offers ease of use with zero code changes; continues utilizing the familiar @nestjs/common logger interface.

  • High Performance: Built on Pino, recognized as one of the fastest logging solutions available in the Node.js ecosystem.

  • Default Context: Automatically enriches logs with correlationId and request duration, providing immediate insights into each request.

  • Platform Agnostic: Compatible with both Express and Fastify, broadening its usability across different Node.js frameworks.

  • Automatic Context Cleanup: Cleans up memory and resources when the request cycle is complete, ensuring efficient resource management.

  • Advanced Context Enrichment: Supports custom context additions at the application level, allowing logs to contain additional relevant information for better tracking.

  • Log Field Grouping: Enables organization of log fields by grouping them, simplifying log querying and readability.

  • Context Propagation: Maintains isolated context for each request while flowing through async operations, which enhances its usefulness during complex execution flows.

express
Express

Express.js is a simple Node.js framework for single, multi-page, and hybrid web applications.

nestjs
Nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.