Nestjs Logger

screenshot of Nestjs Logger

NestJS Full Logger integration example with Winston and Morgan

Overview

If you're working with Nest.js applications and looking for a robust logging solution, this logger built on a clean architecture model may catch your interest. It combines the power of Winston and Morgan to deliver a production-ready logging system that can be seamlessly integrated into both microservices and monolith projects. Its implementation focuses on advanced logging practices while maintaining a modular approach, making it a versatile choice for various project requirements.

This project embraces the Hexagonal Architecture, ensuring that your logging capabilities are well-structured and decoupled from the rest of the application. Whether you're managing simple applications or tackling more complex solutions, this logging system is designed to facilitate better application monitoring and debugging.

Features

  • Hexagonal Architecture: The project is built on Hexagonal Architecture, providing a clean separation of concerns among layers like Application, Domain, and Infrastructure to simplify management and scaling.

  • Winston and Morgan Integration: Utilizes Winston for managing logs and Morgan for logging HTTP requests, offering a powerful combination for comprehensive logging.

  • Correlation IDs Management: Implements correlation IDs to trace requests through the system, enhancing the ability to monitor and debug by capturing unique identifiers for each request lifecycle.

  • Decoupled Logging Libraries: By creating a Logger interface, the logging library is decoupled from the domain, allowing easy replacement or updates without disrupting the core functionality.

  • NestJS Logger Support: Adapts to the NestJS LoggerService interface for internal logging while providing an easy way to integrate custom logging effectively.

  • Logger Context Wrapper: This feature allows the addition of custom metadata to logs, improving the context and relevance of logged information by injecting caller class details into each log entry.

  • Configurable Project Structure: Organized into a monorepo with clear separation among apps, libraries, and shared resources, enhancing maintainability and facilitating collaborative development.

  • Future-Proofing with Open Contributions: The project encourages contributions for continuous improvement and feature expansion, fostering a community around the technology.

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.

webpack
Webpack

Webpack is a popular open-source module bundler for JavaScript applications that bundles and optimizes the code and its dependencies for production-ready deployment. It can also be used to transform other types of assets such as CSS, images, and fonts.