首页 > 解决方案 > 有谁知道如何在 NestJS 中实现 Honeybadger 日志记录?

问题描述

NestJS 使用 express,而 Honeybadger 有一个 express 中间件,但我似乎无法弄清楚如何实现它。目前我的 main.ts 文件看起来像这样

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
import * as Honeybadger from 'honeybadger';

Honeybadger.configure({
  apiKey: '??hidden for security reasons??'
})

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: false,
  });
  app.use(Honeybadger.requestHandler);
  app.use(Honeybadger.errorHandler);
  const configService = app.get(ConfigService);
  await app.listen(configService.get('PORT'));
}

bootstrap();

标签: node.jsexpressloggingnestjs

解决方案


推荐阅读