我想使用 Fastify 忽略或更改 NestJs 应用程序中路由的 logLevel。
这就是我在 Fastify 应用程序中通常的做法。这里我将/health
路由更改logLevel
为,error
以便仅在运行状况出现错误时才会记录。
server.get('/health', { logLevel: 'error' }, async (request, reply) => {
if (mongoose.connection.readyState === 1) {
reply.code(200).send()
} else {
reply.code(500).send()
}
})
Run Code Online (Sandbox Code Playgroud)
但这是我在 NestJs 中的健康控制器
@Get('health')
getHealth(): string {
return this.appService.getHealth()
}
Run Code Online (Sandbox Code Playgroud)
和 main.ts 文件。
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter({
logger: true
}),
)
Run Code Online (Sandbox Code Playgroud)
我不想只记录健康路线而不记录路线。
请在这方面提供帮助。