A configurable Winston logger for NestJS with daily file rotation and console output.
- 📊 Seamless integration with NestJS
- 📅 Daily log rotation with configurable retention
- 📁 Automatic log file organization by log level (info, warn, error)
- 🗜️ Compressed archive support for older logs
- 🎨 Colorized console output for development
- 🔄 JSON formatted logs for production environments
# with npm
npm install @samofprog/nestjs-logstack
# or with yarn
yarn add @samofprog/nestjs-logstack
Note: Ensure you also have
winston
,winston-daily-rotate-file
, and@nestjs/common
as dependencies.
// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { createNestLoggerService } from '@samofprog/nestjs-logstack';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: createNestLoggerService(),
});
await app.listen(3000);
}
bootstrap();
You can also customize the max size and number of days logs are kept:
logger: createNestLoggerService("10m", "7d");