{"_id":"pino-nestjs","_rev":"4-4e19875dde8be6ef9cd90ee0502ee7f1","name":"pino-nestjs","dist-tags":{"latest":"0.1.3"},"versions":{"0.0.0":{"name":"pino-nestjs","version":"0.0.0","keywords":["pino","nestjs","nest.js","nest","logger"],"author":{"url":"http://github.com/yamcodes","name":"yamcodes","email":"yam@yam.codes"},"license":"MIT","_id":"pino-nestjs@0.0.0","maintainers":[{"name":"yamcodes","email":"hi@yam.codes"}],"homepage":"https://github.com/yamcodes/pino-nestjs#readme","bugs":{"url":"https://github.com/yamcodes/pino-nestjs/issues"},"dist":{"shasum":"6da59ce63fb0037035819a4766896c396f438362","tarball":"https://registry.npmjs.org/pino-nestjs/-/pino-nestjs-0.0.0.tgz","fileCount":3,"integrity":"sha512-/SAFy2l3sK9B5U5q/424alG4H0vpdRrGla6An58PYBgmNiP3lUGb3XtB2mVIzk4lnas8A9BC72ZQYhZFDEf4GQ==","signatures":[{"sig":"MEUCIF+avDaAwMydQ1gqSsY5MERP6BcQswc/m2idOPsxoalJAiEAsRKJyr0hfu9gQblkVXymMrJDYRPNNY5hgf3S9zhRR4U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20154},"main":"index.js","_from":"file:pino-nestjs-0.0.0.tgz","types":"index.d.ts","engines":{"node":">= 14"},"scripts":{"lint":"tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix","test":"jest --verbose -i --detectOpenHandles --forceExit","build":"rimraf dist && tsc -p tsconfig.build.json"},"_npmUser":{"name":"yamcodes","email":"hi@yam.codes"},"_resolved":"/private/var/folders/lr/222r_vn57fj40m7_zn11_kdr0000gp/T/20c1486b3ae771ffdba9a56f81959838/pino-nestjs-0.0.0.tgz","_integrity":"sha512-/SAFy2l3sK9B5U5q/424alG4H0vpdRrGla6An58PYBgmNiP3lUGb3XtB2mVIzk4lnas8A9BC72ZQYhZFDEf4GQ==","repository":{"url":"git+https://github.com/yamcodes/pino-nestjs.git","type":"git"},"_npmVersion":"10.9.2","description":"✨ Pino logger for NestJS 8+ with request context in every log ✨","directories":{},"_nodeVersion":"22.13.0","engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jest":"29.7.0","pino":"^9.6.0","rxjs":"^7.8.1","eslint":"^9.18.0","rimraf":"^6.0.1","globals":"^16.0.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","prettier":"^3.4.2","pino-http":"^10.4.0","supertest":"^7.0.0","ts-loader":"^9.5.2","@eslint/js":"^9.18.0","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.7","@nestjs/core":"^11.0.3","memorystream":"^0.3.1","@eslint/compat":"^1.2.5","@nestjs/common":"^11.0.3","@types/express":"^5.0.0","@nestjs/testing":"^11.0.3","@eslint/eslintrc":"^3.2.0","@types/supertest":"^6.0.2","reflect-metadata":"^0.1.14","@types/memorystream":"^0.3.4","eslint-plugin-import":"^2.31.0","eslint-config-prettier":"^10.0.1","eslint-plugin-prettier":"^5.2.3","@nestjs/platform-express":"^11.0.3","@nestjs/platform-fastify":"^11.0.3","@typescript-eslint/parser":"^8.21.0","@typescript-eslint/eslint-plugin":"^8.21.0"},"peerDependencies":{"pino":"^7.5.0 || ^8.0.0 || ^9.0.0","rxjs":"^7.1.0","pino-http":"^6.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0","@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-nestjs_0.0.0_1740754260912_0.017746048132103898","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"pino-nestjs","version":"0.1.0","keywords":["pino","nestjs","nest.js","nest","logger"],"author":{"url":"http://github.com/yamcodes","name":"yamcodes","email":"yam@yam.codes"},"license":"MIT","_id":"pino-nestjs@0.1.0","maintainers":[{"name":"yamcodes","email":"hi@yam.codes"}],"homepage":"https://github.com/yamcodes/pino-nestjs#readme","bugs":{"url":"https://github.com/yamcodes/pino-nestjs/issues"},"dist":{"shasum":"461bbec093afd30195068f17839f29d04151bce2","tarball":"https://registry.npmjs.org/pino-nestjs/-/pino-nestjs-0.1.0.tgz","fileCount":3,"integrity":"sha512-ETfETA/YQ4rKBOkQ28omjsnhDmieBGJyyvyVmlau5pBwzt/IOncJj8riAvVkKvcknAwx/VrU3Y3VtqZjyky1Cw==","signatures":[{"sig":"MEUCIQDgiNGSFlJgK/gFb8qTwvNj84hq7lpdG0GMqmISWuWGHAIgGS0EHXVc+UP+d1parLP+Zfn37lRYtTzPnBi5Dnnhx14=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22550},"main":"index.js","_from":"file:pino-nestjs-0.1.0.tgz","types":"index.d.ts","engines":{"node":">= 14"},"scripts":{"fix":"biome check --write .","lint":"tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix","test":"jest --verbose -i --detectOpenHandles --forceExit","build":"turbo run build:root","check":"biome check","clean":"rimraf dist node_modules","release":"pnpm run build && changeset publish","build:root":"rimraf dist && tsc -p tsconfig.build.json","check:errors":"biome check --diagnostic-level=error"},"_npmUser":{"name":"yamcodes","email":"hi@yam.codes"},"_resolved":"/tmp/e4e3d81fd26948aab90d642c75891c5a/pino-nestjs-0.1.0.tgz","_integrity":"sha512-ETfETA/YQ4rKBOkQ28omjsnhDmieBGJyyvyVmlau5pBwzt/IOncJj8riAvVkKvcknAwx/VrU3Y3VtqZjyky1Cw==","repository":{"url":"git+https://github.com/yamcodes/pino-nestjs.git","type":"git"},"_npmVersion":"10.8.2","description":"✨ Pino logger for NestJS 8+ with request context in every log ✨","directories":{},"_nodeVersion":"20.18.3","engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jest":"29.7.0","pino":"^9.6.0","rxjs":"^7.8.1","turbo":"^2.4.4","rimraf":"^6.0.1","globals":"^16.0.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","pino-http":"^10.4.0","supertest":"^7.0.0","ts-loader":"^9.5.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.7","@nestjs/core":"^11.0.3","memorystream":"^0.3.1","@biomejs/biome":"1.9.4","@nestjs/common":"^11.0.3","@types/express":"^5.0.0","@changesets/cli":"^2.28.1","@nestjs/testing":"^11.0.3","@types/supertest":"^6.0.2","reflect-metadata":"^0.1.14","@types/memorystream":"^0.3.4","@nestjs/platform-express":"^11.0.3","@nestjs/platform-fastify":"^11.0.3","changesets-changelog-clean":"^1.3.0"},"peerDependencies":{"pino":"^7.5.0 || ^8.0.0 || ^9.0.0","rxjs":"^7.1.0","pino-http":"^6.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0","@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-nestjs_0.1.0_1740768623541_0.4051465600537907","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"pino-nestjs","version":"0.1.1","keywords":["pino","nestjs","nest.js","nest","logger"],"author":{"url":"http://github.com/yamcodes","name":"yamcodes","email":"yam@yam.codes"},"license":"MIT","_id":"pino-nestjs@0.1.1","maintainers":[{"name":"yamcodes","email":"hi@yam.codes"}],"homepage":"https://github.com/yamcodes/pino-nestjs#readme","bugs":{"url":"https://github.com/yamcodes/pino-nestjs/issues"},"dist":{"shasum":"ea5e6ab65041d3ff8c5f668e853ebeb669b90cbb","tarball":"https://registry.npmjs.org/pino-nestjs/-/pino-nestjs-0.1.1.tgz","fileCount":28,"integrity":"sha512-jsWP9wontZSZ211rFpcQ5TvMa3asNppismRcOf9SH2nGCtFJx64RhgCVpo8mwQ5UJDuWowfAexfT7jE/XRUAjw==","signatures":[{"sig":"MEUCIQDAlpn9md/i6S4rJpA9fojdVUpC+hTG+1piE+thXRCvSwIgEu4z+qqp2aHTqf+FWr5Loloq5PE+RDkOutXt6vapxUE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":189737},"main":"index.js","_from":"file:pino-nestjs-0.1.1.tgz","types":"index.d.ts","engines":{"node":">= 14"},"scripts":{"fix":"biome check --write .","lint":"tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix","test":"jest --verbose -i --detectOpenHandles --forceExit","build":"turbo run build:root","check":"biome check","clean":"rimraf dist node_modules","release":"pnpm run build && changeset publish","build:root":"rimraf dist && tsc -p tsconfig.build.json","check:errors":"biome check --diagnostic-level=error"},"_npmUser":{"name":"yamcodes","email":"hi@yam.codes"},"_resolved":"/tmp/32747ed331716ebb43cbb22d5b4ad419/pino-nestjs-0.1.1.tgz","_integrity":"sha512-jsWP9wontZSZ211rFpcQ5TvMa3asNppismRcOf9SH2nGCtFJx64RhgCVpo8mwQ5UJDuWowfAexfT7jE/XRUAjw==","repository":{"url":"git+https://github.com/yamcodes/pino-nestjs.git","type":"git"},"_npmVersion":"10.8.2","description":"Drop-in Pino logger for NestJS with request context in every log","directories":{},"_nodeVersion":"20.18.3","engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jest":"29.7.0","pino":"^9.6.0","rxjs":"^7.8.1","turbo":"^2.4.4","rimraf":"^6.0.1","globals":"^16.0.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","pino-http":"^10.4.0","supertest":"^7.0.0","ts-loader":"^9.5.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.7","@nestjs/core":"^11.0.3","memorystream":"^0.3.1","@biomejs/biome":"1.9.4","@nestjs/common":"^11.0.3","@types/express":"^5.0.0","@changesets/cli":"^2.28.1","@nestjs/testing":"^11.0.3","@types/supertest":"^6.0.2","reflect-metadata":"^0.1.14","@types/memorystream":"^0.3.4","@nestjs/platform-express":"^11.0.3","@nestjs/platform-fastify":"^11.0.3","changesets-changelog-clean":"^1.3.0"},"peerDependencies":{"pino":"^7.5.0 || ^8.0.0 || ^9.0.0","rxjs":"^7.1.0","pino-http":"^6.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0","@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-nestjs_0.1.1_1740770224718_0.9267656401378315","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"pino-nestjs","version":"0.1.2","keywords":["pino","nestjs","nest.js","nest","logger"],"author":{"url":"http://github.com/yamcodes","name":"yamcodes","email":"yam@yam.codes"},"license":"MIT","_id":"pino-nestjs@0.1.2","maintainers":[{"name":"yamcodes","email":"hi@yam.codes"}],"homepage":"https://github.com/yamcodes/pino-nestjs#readme","bugs":{"url":"https://github.com/yamcodes/pino-nestjs/issues"},"dist":{"shasum":"f2257b585d82bc4ec89540764234ead5eaa32f11","tarball":"https://registry.npmjs.org/pino-nestjs/-/pino-nestjs-0.1.2.tgz","fileCount":28,"integrity":"sha512-GKZdqN5GqRwDUWxR6nUKmVEFIgQMeqm7E8va8wt4FqWYyZe5UyUVxh9vqgmD082C9jlo69zglJjZM3q1xn94JA==","signatures":[{"sig":"MEUCIG1LPVIEc57EGFNpsXsJfWFxhzNjUGDcDvq340aCt+/4AiEA0bXmf1pExTW6JtT3ctmYnxxIYVbp2f3pskTQ2silkEo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":189747},"main":"dist/index.js","_from":"file:pino-nestjs-0.1.2.tgz","types":"dist/index.d.ts","engines":{"node":">= 14"},"scripts":{"fix":"biome check --write .","lint":"tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix","test":"jest --verbose -i --detectOpenHandles --forceExit","build":"turbo run build:root","check":"biome check","clean":"rimraf dist node_modules","release":"pnpm run build && changeset publish","build:root":"rimraf dist && tsc -p tsconfig.build.json","check:errors":"biome check --diagnostic-level=error"},"_npmUser":{"name":"yamcodes","email":"hi@yam.codes"},"_resolved":"/tmp/b3e9f486e6088180243c76a5aeec8d60/pino-nestjs-0.1.2.tgz","_integrity":"sha512-GKZdqN5GqRwDUWxR6nUKmVEFIgQMeqm7E8va8wt4FqWYyZe5UyUVxh9vqgmD082C9jlo69zglJjZM3q1xn94JA==","repository":{"url":"git+https://github.com/yamcodes/pino-nestjs.git","type":"git"},"_npmVersion":"10.8.2","description":"Drop-in Pino logger for NestJS with request context in every log","directories":{},"_nodeVersion":"20.18.3","engineStrict":true,"_hasShrinkwrap":false,"devDependencies":{"jest":"29.7.0","pino":"^9.6.0","rxjs":"^7.8.1","turbo":"^2.4.4","rimraf":"^6.0.1","globals":"^16.0.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","pino-http":"^10.4.0","supertest":"^7.0.0","ts-loader":"^9.5.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.7","@nestjs/core":"^11.0.3","memorystream":"^0.3.1","@biomejs/biome":"1.9.4","@nestjs/common":"^11.0.3","@types/express":"^5.0.0","@changesets/cli":"^2.28.1","@nestjs/testing":"^11.0.3","@types/supertest":"^6.0.2","reflect-metadata":"^0.1.14","@types/memorystream":"^0.3.4","@nestjs/platform-express":"^11.0.3","@nestjs/platform-fastify":"^11.0.3","changesets-changelog-clean":"^1.3.0"},"peerDependencies":{"pino":"^7.5.0 || ^8.0.0 || ^9.0.0","rxjs":"^7.1.0","pino-http":"^6.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0","@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/pino-nestjs_0.1.2_1740770606293_0.29900510036646466","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"pino-nestjs","version":"0.1.3","description":"Drop-in Pino logger for NestJS with request context in every log","main":"dist/index.js","types":"dist/index.d.ts","engineStrict":true,"engines":{"node":">= 14"},"repository":{"type":"git","url":"git+https://github.com/yamcodes/pino-nestjs.git"},"keywords":["pino","nestjs","nest.js","nest","logger"],"author":{"name":"yamcodes","email":"yam@yam.codes","url":"http://github.com/yamcodes"},"license":"MIT","bugs":{"url":"https://github.com/yamcodes/pino-nestjs/issues"},"homepage":"https://github.com/yamcodes/pino-nestjs#readme","devDependencies":{"@biomejs/biome":"1.9.4","@changesets/cli":"^2.28.1","@nestjs/common":"^11.0.3","@nestjs/core":"^11.0.3","@nestjs/platform-express":"^11.0.3","@nestjs/platform-fastify":"^11.0.3","@nestjs/testing":"^11.0.3","@types/express":"^5.0.0","@types/jest":"^29.5.14","@types/memorystream":"^0.3.4","@types/node":"^22.10.7","@types/supertest":"^6.0.2","changesets-changelog-clean":"^1.3.0","globals":"^16.0.0","jest":"29.7.0","memorystream":"^0.3.1","pino":"^9.6.0","pino-http":"^10.4.0","reflect-metadata":"^0.1.14","rimraf":"^6.0.1","rxjs":"^7.8.1","supertest":"^7.0.0","ts-jest":"^29.2.5","ts-loader":"^9.5.2","ts-node":"^10.9.2","turbo":"^2.4.4","typescript":"^5.7.3"},"peerDependencies":{"@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0","pino":"^7.5.0 || ^8.0.0 || ^9.0.0","pino-http":"^6.4.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0","rxjs":"^7.1.0"},"dependencies":{"radashi":"^12.3.4"},"scripts":{"test":"jest --verbose -i --detectOpenHandles --forceExit","lint":"tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix","build":"turbo run build:root","build:root":"rimraf dist && tsc -p tsconfig.build.json","release":"pnpm run build && changeset publish","fix":"biome check --write .","check":"biome check","check:errors":"biome check --diagnostic-level=error","clean":"rimraf dist node_modules"},"_id":"pino-nestjs@0.1.3","_integrity":"sha512-veKsZ9itAu87zaDuDuVTqdAsSDGEqYFyFrXjqWyHEIs25tm2ReI7o9lZrrwJcoxWPv6PKcddGB8r8ohvcvVqhg==","_resolved":"/tmp/b128e13723baabaaba620b59c522236f/pino-nestjs-0.1.3.tgz","_from":"file:pino-nestjs-0.1.3.tgz","_nodeVersion":"20.18.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-veKsZ9itAu87zaDuDuVTqdAsSDGEqYFyFrXjqWyHEIs25tm2ReI7o9lZrrwJcoxWPv6PKcddGB8r8ohvcvVqhg==","shasum":"397d3110d2f0c71480a142469e1a7771611188a7","tarball":"https://registry.npmjs.org/pino-nestjs/-/pino-nestjs-0.1.3.tgz","fileCount":28,"unpackedSize":190274,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDleRVOwZhuFcBWFuV6G5uTxpo+NfKyCferHZfp+tCMZAIhAM6aGVnQoJaSFSSCbBDfgLe1GMeyYIHjHUteA/C57qUL"}]},"_npmUser":{"name":"yamcodes","email":"hi@yam.codes"},"directories":{},"maintainers":[{"name":"yamcodes","email":"hi@yam.codes"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pino-nestjs_0.1.3_1740788682090_0.8048723893923901"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-28T14:51:00.911Z","modified":"2025-03-01T00:24:42.547Z","0.0.0":"2025-02-28T14:51:01.077Z","0.1.0":"2025-02-28T18:50:23.703Z","0.1.1":"2025-02-28T19:17:04.923Z","0.1.2":"2025-02-28T19:23:26.494Z","0.1.3":"2025-03-01T00:24:42.392Z"},"bugs":{"url":"https://github.com/yamcodes/pino-nestjs/issues"},"author":{"name":"yamcodes","email":"yam@yam.codes","url":"http://github.com/yamcodes"},"license":"MIT","homepage":"https://github.com/yamcodes/pino-nestjs#readme","keywords":["pino","nestjs","nest.js","nest","logger"],"repository":{"type":"git","url":"git+https://github.com/yamcodes/pino-nestjs.git"},"description":"Drop-in Pino logger for NestJS with request context in every log","maintainers":[{"name":"yamcodes","email":"hi@yam.codes"}],"readme":"<h1 align=\"center\">\n  🌲🐱<br /><code>pino-nestjs</code>\n</h1>\n<p align=\"center\">\n  Drop-in Pino logger for NestJS with request context in every log\n</p>\n<p align=\"center\">\n  <a href=\"https://github.com/yamcodes/pino-nestjs/actions/workflows/tests.yml?query=branch%3Amain+event%3Apush\"><img alt=\"Tests Status\" src=\"https://github.com/yamcodes/pino-nestjs/actions/workflows/tests.yml/badge.svg?event=push&branch=main\"></a>\n  <a href=\"https://getpino.io/\"><img alt=\"Powered By pino\" src=\"https://badgen.net/static/powered%20by/pino?color=859947\"></a>\n  <a href=\"https://github.com/pinojs/pino-http\"><img alt=\"Powered By pino-http\" src=\"https://badgen.net/static/powered%20by/pino-http?color=859947\"></a>\n  <a href=\"https://coderabbit.com/\"><img alt=\"CodeRabbit Pull Request Reviews\" src=\"https://img.shields.io/coderabbit/prs/github/yamcodes/pino-nestjs?color=859947\"></a>\n</p>\n\nKeep your NestJS logs while gaining all the benefits of [pino](https://getpino.io/) and [pino-http](https://github.com/pinojs/pino-http): structured JSON logs, exceptional performance, and automatic request context tracking.\n\n```ts\n// Other loggers - violate NestJS parameter order\nthis.logger.log(context, 'message'); // ❌ context first, message second\n\n// With pino-nestjs - respect NestJS parameter order\nthis.logger.log('message', context); // ✅ message first, context second\n```\n\n`pino-nestjs` is a **true drop-in replacement for NestJS's built-in logger**.\n\n## Table of contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Comparison with other loggers](#comparison-with-other-loggers)\n- [Configuration](#configuration)\n  - [Zero configuration](#zero-configuration)\n  - [Configuration parameters](#configuration-parameters)\n  - [Synchronous configuration](#synchronous-configuration)\n  - [Asynchronous configuration](#asynchronous-configuration)\n  - [Asynchronous logging](#asynchronous-logging)\n- [Testing](#testing-a-class-that-uses-injectpinologger)\n- [Extending logger classes](#logger-and-pinologger-class-extension)\n- [Notes on logger injection](#notes-on-logger-injection-in-constructor)\n- [Additional features](#assign-extra-fields-for-future-calls)\n  - [Assign extra fields](#assign-extra-fields-for-future-calls)\n  - [Change Pino parameters at runtime](#change-pino-params-at-runtime)\n  - [Expose stack trace](#expose-stack-trace-and-error-class-in-err-property)\n- [Frequently asked questions](#frequently-asked-questions)\n\n## Installation\n\n```sh\nnpm i pino-nestjs pino-http\n```\n\n## Usage\n\n### Import the module\n\nImport `LoggerModule` in your root module:\n\n```ts\nimport { LoggerModule } from 'pino-nestjs';\n\n@Module({\n  imports: [LoggerModule.forRoot()],\n})\nclass AppModule {}\n```\n\n### Set up app logger\n\n```ts\nimport { Logger } from 'pino-nestjs';\n\nconst app = await NestFactory.create(AppModule, { bufferLogs: true });\napp.useLogger(app.get(Logger));\n```\n\n### Use one of two logger options\n\n#### Option 1: NestJS standard logger (recommended)\n\n```ts\n// NestJS standard built-in logger.\n// Logs will be produced by pino internally\nimport { Logger } from '@nestjs/common';\n\nexport class MyService {\n  private readonly logger = new Logger(MyService.name);\n  \n  foo() {\n    // NestJS parameter order: message first, then context (if needed)\n    // With pino-nestjs, you can use the standard NestJS logging pattern\n    this.logger.verbose('My verbose message', MyService.name);\n    this.logger.debug('User data processed', { userId: '123', status: 'success' });\n    this.logger.log('Operation completed', MyService.name);\n    \n    // Object logging also works with NestJS parameter order\n    this.logger.warn({ operation: 'data_sync', status: 'warning' }, MyService.name);\n    \n    // Error logging\n    try {\n      // Some operation\n    } catch (error) {\n      this.logger.error(error, error.stack, MyService.name);\n    }\n  }\n}\n```\n\n#### Option 2: Direct Pino Logger\n\n```ts\nimport { PinoLogger, InjectPinoLogger } from 'pino-nestjs';\n\nexport class MyService {\n  constructor(\n    private readonly logger: PinoLogger\n  ) {\n    // Optionally set context in constructor\n    this.logger.setContext(MyService.name);\n  }\n\n  // Alternative: use decorator to set context\n  constructor(\n    @InjectPinoLogger(MyService.name)\n    private readonly logger: PinoLogger\n  ) {}\n\n  foo() {\n    // When using PinoLogger directly, you still have access to Pino's native format\n    // But pino-nestjs also supports NestJS parameter order: message first, then context\n    this.logger.trace('This is a trace message');\n    this.logger.debug('Debug information', { userId: '123' });\n    this.logger.info('Information message', MyService.name);\n    \n    // Traditional Pino object + message format also works\n    this.logger.trace({ operation: 'init' }, 'System initialized');\n  }\n}\n```\n\n### Log output example\n\n```json\n// App logs\n{\"level\":30,\"time\":1629823318326,\"pid\":14727,\"hostname\":\"my-host\",\"context\":\"NestFactory\",\"msg\":\"Starting Nest application...\"}\n{\"level\":30,\"time\":1629823318326,\"pid\":14727,\"hostname\":\"my-host\",\"context\":\"InstanceLoader\",\"msg\":\"LoggerModule dependencies initialized\"}\n{\"level\":30,\"time\":1629823318327,\"pid\":14727,\"hostname\":\"my-host\",\"context\":\"InstanceLoader\",\"msg\":\"AppModule dependencies initialized\"}\n{\"level\":30,\"time\":1629823318327,\"pid\":14727,\"hostname\":\"my-host\",\"context\":\"RoutesResolver\",\"msg\":\"AppController {/}:\"}\n{\"level\":30,\"time\":1629823318327,\"pid\":14727,\"hostname\":\"my-host\",\"context\":\"RouterExplorer\",\"msg\":\"Mapped {/, GET} route\"}\n{\"level\":30,\"time\":1629823318327,\"pid\":14727,\"hostname\":\"my-host\",\"context\":\"NestApplication\",\"msg\":\"Nest application successfully started\"}\n\n// Service logs with request context and req.id\n{\"level\":10,\"time\":1629823792023,\"pid\":15067,\"hostname\":\"my-host\",\"req\":{\"id\":1,\"method\":\"GET\",\"url\":\"/\",\"query\":{},\"params\":{\"0\":\"\"},\"headers\":{\"host\":\"localhost:3000\",\"user-agent\":\"curl/7.64.1\",\"accept\":\"*/*\"},\"remoteAddress\":\"::1\",\"remotePort\":63822},\"context\":\"MyService\",\"foo\":\"bar\",\"msg\":\"baz qux\"}\n{\"level\":20,\"time\":1629823792023,\"pid\":15067,\"hostname\":\"my-host\",\"req\":{\"id\":1,\"method\":\"GET\",\"url\":\"/\",\"query\":{},\"params\":{\"0\":\"\"},\"headers\":{\"host\":\"localhost:3000\",\"user-agent\":\"curl/7.64.1\",\"accept\":\"*/*\"},\"remoteAddress\":\"::1\",\"remotePort\":63822},\"context\":\"MyService\",\"msg\":\"foo bar {\\\"baz\\\":\\\"qux\\\"}\"}\n{\"level\":30,\"time\":1629823792023,\"pid\":15067,\"hostname\":\"my-host\",\"req\":{\"id\":1,\"method\":\"GET\",\"url\":\"/\",\"query\":{},\"params\":{\"0\":\"\"},\"headers\":{\"host\":\"localhost:3000\",\"user-agent\":\"curl/7.64.1\",\"accept\":\"*/*\"},\"remoteAddress\":\"::1\",\"remotePort\":63822},\"context\":\"MyService\",\"msg\":\"foo\"}\n\n// Automatic request/response logs\n{\"level\":30,\"time\":1629823792029,\"pid\":15067,\"hostname\":\"my-host\",\"req\":{\"id\":1,\"method\":\"GET\",\"url\":\"/\",\"query\":{},\"params\":{\"0\":\"\"},\"headers\":{\"host\":\"localhost:3000\",\"user-agent\":\"curl/7.64.1\",\"accept\":\"*/*\"},\"remoteAddress\":\"::1\",\"remotePort\":63822},\"res\":{\"statusCode\":200,\"headers\":{\"x-powered-by\":\"Express\",\"content-type\":\"text/html; charset=utf-8\",\"content-length\":\"12\",\"etag\":\"W/\\\"c-Lve95gjOVATpfV8EL5X4nxwjKHE\\\"\"}},\"responseTime\":7,\"msg\":\"request completed\"}\n```\n\n## Comparison with other loggers\n\nKey features of this module:\n\n- Idiomatic NestJS logger\n- JSON format logging (via [pino](https://getpino.io/) - [super fast logger](https://github.com/pinojs/pino/blob/master/docs/benchmarks.md))\n- Automatic request/response logging (via [pino-http](https://github.com/pinojs/pino-http))\n- Request data binding to logs from any service without passing context (via [AsyncLocalStorage](https://nodejs.org/api/async_context.html#async_context_class_asynclocalstorage))\n- Alternative `PinoLogger` with the same API as `pino` for experienced pino users\n- **NestJS compatible parameter order** (message first, context second) for direct compatibility with NestJS Logger\n\n### Differences from nestjs-pino\n\n`pino-nestjs` is a fork of [nestjs-pino](https://github.com/iamolegga/nestjs-pino) with one key improvement: **parameter order compatibility with NestJS**.\n\nSee [nestjs-pino#2004](https://github.com/iamolegga/nestjs-pino/issues/2004) to understand the motivation for this fork.\n\n```typescript\n// With nestjs-pino (Pino style):\nthis.logger.log({ foo: 'bar' }, 'Hello World');\n\n// With pino-nestjs (NestJS style):\nthis.logger.log('Hello World', { foo: 'bar' });\n```\n\nUnlike nestjs-pino which follows Pino's convention (context first, then message), `pino-nestjs` acts as a true drop-in replacement for NestJS's built-in Logger by using the NestJS parameter order (message first, then context).\n\n| Logger | Nest App Logger | Logger Service | Auto-bind Request Data | NestJS Parameter Order |\n|--------|:--------------:|:--------------:|:----------------------:|:----------------------:|\n| [nest-winston](https://github.com/gremo/nest-winston) | ✅ | ✅ | ❌ | ✅ |\n| [nestjs-pino-logger](https://github.com/jtmthf/nestjs-pino-logger) | ✅ | ✅ | ❌ | ✅ |\n| [nestjs-pino](https://github.com/iamolegga/nestjs-pino) | ✅ | ✅ | ✅ | ❌ |\n| [**pino-nestjs**](https://github.com/yamcodes/pino-nestjs) | ✅ | ✅ | ✅ | ✅ |\n\n## Configuration\n\n### Zero configuration\n\n```ts\nimport { LoggerModule } from 'pino-nestjs';\n\n@Module({\n  imports: [LoggerModule.forRoot()],\n  // ...\n})\nclass MyModule {}\n```\n\n### Configuration parameters\n\n```ts\ninterface Params {\n  /**\n   * Optional parameters for `pino-http` module\n   * @see https://github.com/pinojs/pino-http#api\n   */\n  pinoHttp?:\n    | pinoHttp.Options\n    | DestinationStream\n    | [pinoHttp.Options, DestinationStream];\n\n  /**\n   * Optional parameter for routing. Implements interface of\n   * NestJS built-in `MiddlewareConfigProxy['forRoutes']`.\n   * @see https://docs.nestjs.com/middleware#applying-middleware\n   */\n  forRoutes?: Parameters<MiddlewareConfigProxy['forRoutes']>;\n\n  /**\n   * Optional parameter for routing. Implements interface of\n   * NestJS built-in `MiddlewareConfigProxy['exclude']`.\n   * @see https://docs.nestjs.com/middleware#applying-middleware\n   */\n  exclude?: Parameters<MiddlewareConfigProxy['exclude']>;\n\n  /**\n   * Optional parameter to skip pino configuration when using\n   * FastifyAdapter with pre-configured logger.\n   * @see https://github.com/yamcodes/pino-nestjs#faq\n   */\n  useExisting?: true;\n\n  /**\n   * Optional parameter to change property name `context` in logs\n   */\n  renameContext?: string;\n}\n```\n\n### Synchronous configuration\n\n```ts\nimport { LoggerModule } from 'pino-nestjs';\n\n@Module({\n  imports: [\n    LoggerModule.forRoot({\n      pinoHttp: [\n        {\n          name: 'my-app-name',\n          level: process.env.NODE_ENV !== 'production' ? 'debug' : 'info',\n          // Install 'pino-pretty' package to use this option\n          transport: process.env.NODE_ENV !== 'production'\n            ? { target: 'pino-pretty' }\n            : undefined,\n          // Other pino-http options:\n          // https://github.com/pinojs/pino-http#api\n          // https://github.com/pinojs/pino/blob/HEAD/docs/api.md#options-object\n        },\n        someWritableStream\n      ],\n      forRoutes: [MyController],\n      exclude: [{ method: RequestMethod.ALL, path: 'check' }]\n    })\n  ],\n  // ...\n})\nclass MyModule {}\n```\n\n### Asynchronous configuration\n\n```ts\nimport { LoggerModule } from 'pino-nestjs';\n\n@Injectable()\nclass ConfigService {\n  public readonly level = 'debug';\n}\n\n@Module({\n  providers: [ConfigService],\n  exports: [ConfigService]\n})\nclass ConfigModule {}\n\n@Module({\n  imports: [\n    LoggerModule.forRootAsync({\n      imports: [ConfigModule],\n      inject: [ConfigService],\n      useFactory: async (config: ConfigService) => {\n        await somePromise();\n        return {\n          pinoHttp: { level: config.level },\n        };\n      }\n    })\n  ],\n  // ...\n})\nclass TestModule {}\n```\n\n### Asynchronous logging\n\n> Asynchronous logging enables even faster performance by pino but risks losing the most recently buffered logs in case of system failure.\n\nRead [pino asynchronous mode docs](https://github.com/pinojs/pino/blob/master/docs/asynchronous.md) first.\n\n```ts\nimport pino from 'pino';\nimport { LoggerModule } from 'pino-nestjs';\n\n@Module({\n  imports: [\n    LoggerModule.forRoot({\n      pinoHttp: {\n        stream: pino.destination({\n          dest: './my-file', // omit for stdout\n          minLength: 4096, // Buffer before writing\n          sync: false, // Asynchronous logging\n        }),\n      },\n    }),\n  ],\n  // ...\n})\nclass MyModule {}\n```\n\nSee [pino.destination](https://github.com/pinojs/pino/blob/master/docs/api.md#pino-destination)\n\n## Testing a class that uses @InjectPinoLogger\n\nThe package exposes a `getLoggerToken()` function that returns an injection token based on the provided context:\n\n```ts\nconst module: TestingModule = await Test.createTestingModule({\n  providers: [\n    MyService,\n    {\n      provide: getLoggerToken(MyService.name),\n      useValue: mockLogger,\n    },\n  ],\n}).compile();\n```\n\n## Logger and PinoLogger class extension\n\nBoth classes can be extended:\n\n```ts\n// logger.service.ts\nimport { Logger, PinoLogger, Params, PARAMS_PROVIDER_TOKEN } from 'pino-nestjs';\n\n@Injectable()\nclass LoggerService extends Logger {\n  constructor(\n    logger: PinoLogger,\n    @Inject(PARAMS_PROVIDER_TOKEN) params: Params\n  ) {\n    super();\n    // ...\n  }\n  // Extended method\n  myMethod(): any {}\n}\n\n// Alternative: Extend PinoLogger\n@Injectable()\nclass LoggerService extends PinoLogger {\n  constructor(\n    @Inject(PARAMS_PROVIDER_TOKEN) params: Params\n  ) {\n    super();\n    // ...\n  }\n  // Extended method\n  myMethod(): any {}\n}\n\n// logger.module.ts\n@Module({\n  providers: [LoggerService],\n  exports: [LoggerService],\n  imports: [LoggerModule.forRoot()],\n})\nclass LoggerModule {}\n```\n\n## Notes on logger injection in constructor\n\nSince NestJS@8, the main purpose of the `Logger` class is to be registered via `app.useLogger(app.get(Logger))`. With this usage, NestJS passes the logger's context as the last optional argument in logging functions.\n\nThis creates a limitation in detecting whether a method was called by app internals (where the last argument is context) or by an injected `Logger` instance in a service (where the last argument might be an interpolation value).\n\n## Reuse the Fastify logger configuration\n\n> [!WARNING]\n> This feature is not recommended for most cases. Read on to understand the caveats.\n\nIf you use `useExisting: true` with Fastify, you can reuse the Fastify logger configuration by providing the same options in `forRoot`/`forRootAsync`:\n\n```ts\nimport { LoggerModule } from 'pino-nestjs'; \n\n@Module({\n  imports: [\n    LoggerModule.forRoot({\n      useExisting: true,\n    }),\n  ],\n})\nclass MyModule {} \n```\n\nWhen working with Fastify and pino-nestjs together, you need to understand how logger instances are managed:\n\n1. **Request vs. Application Context**:\n   - Fastify creates a logger with your configuration for each request\n   - NestJS has additional execution contexts (like lifecycle events) that occur outside request context\n   - For these non-request contexts, `Logger`/`PinoLogger` services use a separate pino instance configured via `forRoot`/`forRootAsync`\n\n2. **Configuration Sharing Issues**:\n   - When configuring pino via `FastifyAdapter`, there's no way to extract that configuration and apply it to the out-of-context logger\n   - Without explicit configuration in `forRoot`/`forRootAsync`, the out-of-context logger will use default parameters\n\n3. **Potential Solutions**:\n   - For consistency, you must provide identical configurations to both Fastify and LoggerModule\n   - Better approach: configure only through LoggerModule and drop the `useExisting` option entirely\n\n4. **When to use `useExisting: true`**:\n   - Only when you don't need logging for lifecycle events and application-level logging\n   - Only when using pino with default parameters in Fastify-based NestJS apps\n\nFor all other scenarios, using `useExisting: true` will lead to either code duplication or unexpected behavior.\n\n## Assign extra fields for future calls\n\nYou can enrich logs using the `assign` method of `PinoLogger`:\n\n```ts\n@Controller('/')\nclass TestController {\n  constructor(\n    private readonly logger: PinoLogger,\n    private readonly service: MyService,\n  ) {}\n\n  @Get()\n  get() {\n    // Assign extra fields in one place...\n    this.logger.assign({ userID: '42' });\n    return this.service.test();\n  }\n}\n\n@Injectable()\nclass MyService {\n  private readonly logger = new Logger(MyService.name);\n\n  test() {\n    // ...and it will be logged in another place\n    this.logger.log('hello world');\n  }\n}\n```\n\nSet the `assignResponse` parameter to `true` to also enrich request completion logs.\n\n## Change Pino parameters at runtime\n\nYou can modify pino root logger parameters at runtime:\n\n```ts\n@Controller('/')\nclass TestController {\n  @Post('/change-logging-level')\n  setLevel() {\n    PinoLogger.root.level = 'info';\n    return null;\n  }\n}\n```\n\n## Expose stack trace and error class in `err` property\n\nUse the provided interceptor to expose actual error details:\n\n```typescript\nimport { LoggerErrorInterceptor } from 'pino-nestjs';\n\nconst app = await NestFactory.create(AppModule);\napp.useGlobalInterceptors(new LoggerErrorInterceptor());\n```\n\n## Frequently asked questions\n\n#### Q: How do I disable automatic request/response logs?\n\n**A**: Use the [autoLogging field of pino-http](https://github.com/pinojs/pino-http#pinohttpopts-stream) in the `pinoHttp` configuration.\n\n#### Q: How do I pass `X-Request-ID` header or generate UUID for `req.id`?\n\n**A**: Use the [genReqId field of pino-http](https://github.com/pinojs/pino-http#pinohttpopts-stream) in the `pinoHttp` configuration.\n\n#### Q: How does it work?\n\n**A**: It uses [pino-http](https://github.com/pinojs/pino-http) to create a child-logger for each request, and with [AsyncLocalStorage](https://nodejs.org/api/async_context.html#async_context_class_asynclocalstorage), `Logger` and `PinoLogger` can access it from any service. This allows logs to be grouped by `req.id`.\n\n#### Q: Why use [AsyncLocalStorage](https://nodejs.org/api/async_context.html#async_context_class_asynclocalstorage) instead of [REQUEST scope](https://docs.nestjs.com/fundamentals/injection-scopes#per-request-injection)?\n\n**A**: REQUEST scope can have [performance issues](https://docs.nestjs.com/fundamentals/injection-scopes#performance) as it creates new instances of each service per request.\n\n#### Q: What about `pino` built-in methods/levels?\n\n**A**: Here's the mapping between methods:\n\n| `pino` | `PinoLogger` | NestJS `Logger` |\n|--------|--------------|-----------------|\n| **trace** | **trace** | **verbose** |\n| debug | debug | debug |\n| **info** | **info** | **log** |\n| warn | warn | warn |\n| error | error | error |\n| fatal | fatal | fatal (since nestjs@10.2) |\n\n#### Q: I use Fastify and want to configure pino at the Adapter level. Can I use that config for the logger?\n\n**A**: You can use `useExisting: true`, but there are [caveats](#reuse-the-fastify-logger-configuration).","readmeFilename":"README.md"}