diff --git a/packages/server/package.json b/packages/server/package.json index cecfd906..3135acb1 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -42,6 +42,7 @@ "ioredis": "^5.4.1", "js-yaml": "^4.1.0", "mysql2": "^3.11.3", + "nest-winston": "1.9.7", "passport": "^0.7.0", "passport-google-oauth20": "^2.0.0", "passport-kakao": "^1.0.1", @@ -50,6 +51,8 @@ "tunnel-ssh": "^5.1.2", "typeorm": "^0.3.20", "uuid": "^11.0.3", + "winston": "^3.17.0", + "winston-daily-rotate-file": "^5.0.0", "ws": "^8.18.0" }, "devDependencies": { @@ -67,6 +70,7 @@ "@types/passport-kakao": "^1", "@types/socket.io": "^3.0.2", "@types/supertest": "^6.0.0", + "@types/winston": "^2.4.4", "@types/ws": "^8.5.13", "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", diff --git a/packages/server/src/app.module.ts b/packages/server/src/app.module.ts index b436e9dc..ea92901f 100644 --- a/packages/server/src/app.module.ts +++ b/packages/server/src/app.module.ts @@ -12,10 +12,12 @@ import { RedisModule } from './redis/redis.module'; import { ScheduleModule as NestScheduleModule } from '@nestjs/schedule'; import { ScheduleModule } from './schedule/schedule.module'; import { TradehistoryModule } from './trade-history/trade-history.module'; +import { WinstonModule } from 'nest-winston'; +import { winstonConfig } from 'config/winston.config'; @Module({ imports: [ - AuthModule, + AuthModule, HealthModule, AccountModule, TradeModule, @@ -29,6 +31,7 @@ import { TradehistoryModule } from './trade-history/trade-history.module'; NestScheduleModule.forRoot(), ScheduleModule, TradehistoryModule, + WinstonModule.forRoot(winstonConfig), ], controllers: [AppController], providers: [AppService], diff --git a/packages/server/src/main.ts b/packages/server/src/main.ts index 828a6213..fe5c6abc 100644 --- a/packages/server/src/main.ts +++ b/packages/server/src/main.ts @@ -8,12 +8,16 @@ import { import { config } from 'dotenv'; import { setupSshTunnel } from './configs/ssh-tunnel'; import { AllExceptionsFilter } from 'common/all-exceptions.filter'; +import { WinstonModule } from 'nest-winston'; +import { winstonConfig } from 'config/winston.config'; config(); async function bootstrap() { await setupSshTunnel(); - const app = await NestFactory.create(AppModule); + const app = await NestFactory.create(AppModule,{ + logger: WinstonModule.createLogger(winstonConfig) + }); app.enableCors({ origin: true, methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',