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);