From c4353815179f7f76b409f3087050ea946edda55e Mon Sep 17 00:00:00 2001 From: Soap Date: Sat, 16 Nov 2024 12:18:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A1=9C=EA=B1=B0=20=ED=83=80=EC=9E=84?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EC=84=A4=EC=A0=95,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=9A=A9=20=EB=A1=9C=EA=B9=85=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?#133?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/app.controller.ts | 7 ++++++- backend/src/common/log/logger.ts | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/app.controller.ts b/backend/src/app.controller.ts index 561e7ce7..e5ec9770 100644 --- a/backend/src/app.controller.ts +++ b/backend/src/app.controller.ts @@ -1,12 +1,17 @@ import { Controller, Get } from '@nestjs/common'; import { AppService } from './app.service'; +import { PinoLogger } from 'nestjs-pino'; @Controller() export class AppController { - constructor(private readonly appService: AppService) {} + constructor( + private readonly logger: PinoLogger, + private readonly appService: AppService, + ) {} @Get() async getHello() { + this.logger.info('Hello world'); return (await this.appService.getHello()) + ' Web 09 Backend'; } } diff --git a/backend/src/common/log/logger.ts b/backend/src/common/log/logger.ts index 23a964e6..deb23cf1 100644 --- a/backend/src/common/log/logger.ts +++ b/backend/src/common/log/logger.ts @@ -48,7 +48,11 @@ const logstashLoggerOptions = { export function createLogger(host: string, port: number) { if (process.env.NODE_ENV === 'prod') { - const stream = net.createConnection({ host, port }); + const stream = net.createConnection({ host, port, timeout: 5000 }); + stream.on('error', (err) => { + console.error('Log Stream connection error:', err); + }); + return pino(logstashLoggerOptions, stream); } return pino(consoleLoggerOptions);