nest-winston

Nest module wrapper wiring winston logging into NestJS's DI and Logger interface

Library
npm
v2.0.0
731 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
67 /100 Good
Development Activity 80
Maintenance 40
Community 60
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
71 /100 Good
Architecture 73
Code Quality 74
Innovation 58
Learning Curve 80

nest-winston integrates the winston logging library into NestJS applications as a proper Nest module, so a winston logger instance is registered through Nest’s dependency-injection container instead of being imported as a bare global object. It implements Nest’s LoggerService interface, letting a winston logger fully replace Nest’s built-in console logger (including framework-internal log calls) via app.useLogger().

The module supports both synchronous (forRoot) and async factory-based (forRootAsync) configuration, exposes a standalone WinstonModule.createLogger() for use before the Nest application context exists (e.g. bootstrap-time logging), and ships Nest-flavored winston formatting utilities (nestLike) that mimic the default Nest console output while running through winston’s transport pipeline.

What You Get

  • WinstonModule.forRoot() / forRootAsync() to register a configured winston logger as an injectable Nest provider
  • WinstonModule.createLogger() for bootstrap-time logging before the Nest app context is created
  • A LoggerService-compatible wrapper so app.useLogger() can replace Nest’s console logger app-wide, including internal framework logs
  • utilities.format.nestLike() winston formatter reproducing Nest’s familiar colored console output through winston transports
  • Full access to winston’s transport ecosystem (files, HTTP, third-party log services) from within a standard Nest provider

Common Use Cases

  • Replacing Nest’s built-in console logger app-wide with winston so logs can be shipped to files, log aggregators, or external services
  • Structured JSON logging for production Nest APIs consumed by log pipelines (ELK, Datadog, CloudWatch)
  • Keeping Nest’s familiar colored console format in development while switching to JSON/file transports in production, via the same logger configuration
  • Capturing bootstrap-phase log messages (before DI is available) with createLogger() so early startup errors aren’t lost

Under The Hood

Architecture - WinstonModule (src/winston.module.ts) is a @Global() dynamic module exposing three static entry points — forRoot, forRootAsync, and createLogger — all of which delegate to factory functions in winston.providers.ts that construct the actual winston logger instance and wrap it to satisfy Nest’s LoggerService interface (log/error/warn/debug/verbose methods). winston.classes.ts and winston.utilities.ts provide the adapter class and the nestLike formatter, which reconstructs Nest’s default colored console format as a winston format function so switching loggers doesn’t change local dev output. The dependency on fast-safe-stringify protects the formatter from crashing when logged objects contain circular references.

Tech Stack - TypeScript built with tsc, tested with Jest, linted with ESLint; peer dependencies on @nestjs/common/@nestjs/core and a direct dependency on winston itself plus fast-safe-stringify for safe object serialization in log formatting. A sample/ directory provides a runnable example Nest app demonstrating setup.

Code Quality - Two spec files (winston.module.spec.ts, winston.utilities.spec.ts) cover module registration and the custom formatting utilities under Jest. The module surface is small (module, providers, interfaces, constants, classes, utilities each in their own file), keeping the wrapper thin and auditable rather than reimplementing winston behavior.

API Design - The three static methods mirror the same forRoot/forRootAsync convention used across the Nest ecosystem (config modules, TypeORM, etc.), so developers already familiar with Nest’s dynamic-module pattern need no new concepts. createLogger() addressing the pre-bootstrap logging gap is a deliberate ergonomic addition beyond a bare winston wrapper, and the nestLike formatter specifically targets the common complaint that swapping loggers usually means losing Nest’s readable dev console output.

Used by 6 apps in this directory

TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 5 days ago
TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,626

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 2 months ago
JavaScript
57%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,007

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
JavaScript 57%
TypeScript 36%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers