{"id":22308842,"url":"https://github.com/pay-k/nestjs-winston","last_synced_at":"2025-07-29T06:31:07.536Z","repository":{"id":35120773,"uuid":"209095849","full_name":"pay-k/nestjs-winston","owner":"pay-k","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-30T18:40:49.000Z","size":172,"stargazers_count":10,"open_issues_count":11,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T13:16:05.115Z","etag":null,"topics":["nest","nestjs-logger","winston"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pay-k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-17T15:51:57.000Z","updated_at":"2021-05-06T20:06:53.000Z","dependencies_parsed_at":"2023-01-15T14:14:51.292Z","dependency_job_id":null,"html_url":"https://github.com/pay-k/nestjs-winston","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pay-k/nestjs-winston","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pay-k%2Fnestjs-winston","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pay-k%2Fnestjs-winston/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pay-k%2Fnestjs-winston/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pay-k%2Fnestjs-winston/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pay-k","download_url":"https://codeload.github.com/pay-k/nestjs-winston/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pay-k%2Fnestjs-winston/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267639569,"owners_count":24119780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nest","nestjs-logger","winston"],"created_at":"2024-12-03T20:15:36.815Z","updated_at":"2025-07-29T06:31:07.178Z","avatar_url":"https://github.com/pay-k.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\nnestjs-winston\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com\"\u003e\u003cimg src=\"https://nestjs.com/img/logo_text.svg\" width=\"320\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Winston for \u003ca href=\"https://github.com/nestjs/nest\"\u003eNestJS\u003c/a\u003e has never been this easy!\n  \u003cbr /\u003e\u003cbr /\u003e\n  \u003ca href=\"https://dev.azure.com/payk/PayK%20Public/_build/latest?definitionId=3\u0026branchName=master\"\u003e\u003cimg src=\"https://dev.azure.com/payk/PayK%20Public/_apis/build/status/pay-k.nestjs-winston?branchName=master\" /\u003e\u003c/a\u003e\n\n## Installation\n\n```bash\nnpm install --save @payk/nestjs-winston\n```\n\n## What does it do?\nThis package not only wraps winston into a Nest Module like other packages, it also creates a \u003cb\u003eNest LoggerService\u003c/b\u003e, so you can keep using the default NestJS logger, which enjoying winston.\nBut that's not all, it also takes those great things from the NestJS Logger. It adds the context into the winston meta (so it can later be search and indexed in your \u003cb\u003eELK/Datadog\u003c/b\u003e).\n\nAnother great feature is the \u003cb\u003ewinston formatter\u003c/b\u003e add to the class that in local mode allows easy and readable logs to the console.\n\n## Quick Start\n\nImport `WinstonModule` and use the `forRoot()` method to configure it. This method accepts the same options object as [`createLogger()`](https://github.com/winstonjs/winston#usage) function from the winston package:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { WinstonModule } from '@payk/nestjs-winston';\nimport * as winston from 'winston';\n\n@Module({\n  imports: [\n    WinstonModule.forRoot({\n      // options here\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n\n## Async configuration\n\n\u003e **Caveats**: because the way Nest works, you can't inject dependencies exported from the root module itself (using `exports`). If you use `forRootAsync()` and need to inject a service, that service must be either imported using the `imports` options or exported from a [global module](https://docs.nestjs.com/modules#global-modules).\n\nMaybe you need to asynchronously pass your module options, for example when you need a configuration service. In such case, use the `forRootAsync()` method, returning an options object from the `useFactory` method:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { WinstonModule } from '@payk/nestjs-winston';\nimport * as winston from 'winston';\n\n@Module({\n  imports: [\n    WinstonModule.forRootAsync({\n      useFactory: () =\u003e ({\n        // options\n      }),\n      inject: [],\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nThe factory might be async, can inject dependencies with `inject` option and import other modules using the `imports` option.\n\n## Use as the main Nest Logger (preferred way)\n\nIf you want to use winston logger across the whole app, including bootstrapping and error handling, use the following:\n\nDefine:\n```typescript\nimport { WINSTON_MODULE_NEST_PROVIDER } from '@payk/nestjs-winston';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule);\n  app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));\n}\nbootstrap();\n```\n\nUse:\n```typescript\nimport { WinstonLogger } from '@payk/nestjs-winston';\n\nexport class ClassName {\n  private readonly logger = new WinstonLogger(ClassName.name);\n}\n```\n\n## Nest Winston Formatter\nTo allow a better visibility a unique formatter is provided\n```typescript\nimport { winstonConsoleFormat } from '@payk/nestjs-winston';\n\nWinstonModule.forRoot({\n  level: 'info',\n  //format: winston.format.json(),\n  defaultMeta: { service: 'user-service' },\n  transports: [\n\n    new winston.transports.Console({\n      format: winston.format.combine(\n                winston.format.timestamp(),\n                winston.format.colorize({ all: true }),\n                winstonConsoleFormat\n              )\n    })\n  ]\n})\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpay-k%2Fnestjs-winston","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpay-k%2Fnestjs-winston","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpay-k%2Fnestjs-winston/lists"}