Unilog is request context logger for NestJS.
$ npm install --save nestjs-unilog
import { UnilogModule, RequestContextLogger } from "nestjs-unilog"
import { Module } from "@nestjs/common"
import { NestFactory } from "@nestjs/core"
// 1. Register UnilogModule
@Module({ imports: [UnilogModule] })
class AppModule {}
async function bootstrap() {
const app = await NestFactory.create(AppModule)
// 2. Use RequestContextLogger
app.useLogger(app.get(RequestContextLogger))
await app.listen(3000)
}
bootstrap()
- Author - Rahul Kadyan
- Twitter - @znck0
NestJS Unilog is MIT licensed.