nest-winston

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

Library
npm
v1.10.2
729stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
57/100Fair
Development Activity64
Maintenance16
Community60
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture73
Code Quality74
Innovation58
Learning Curve80

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
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

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
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

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

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

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
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

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

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,618

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

View details
53
Repo Health
66
Technical
64
Dependency
Built with
TypeScript94%
Updated 1 months ago
JavaScript
59%
AGPL 3.0

ToolJet

Low Code Platforms · No Code Platforms · AI Agents

40,458

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
65
Dependency
Built with
JavaScript59%
TypeScript33%
Updated today

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

Search