Description
The Winston logger in /backend/src/services/logger.ts (or wherever it is configured) does not have log rotation configured. In production, log files will grow indefinitely until the disk fills up and the server crashes.
Current State
Winston is configured with file transports but no rotation:
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
A busy production server logging every request and blockchain event will generate hundreds of MB per day.
Fix
Use winston-daily-rotate-file:
npm install winston-daily-rotate-file
import DailyRotateFile from 'winston-daily-rotate-file';
const transport = new DailyRotateFile({
filename: 'logs/application-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m', // rotate when file reaches 20MB
maxFiles: '14d', // keep 14 days of logs
level: 'info',
});
const errorTransport = new DailyRotateFile({
filename: 'logs/error-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '10m',
maxFiles: '30d',
level: 'error',
});
const logger = winston.createLogger({
transports: [transport, errorTransport],
});
Additional Steps
Acceptance Criteria
Description
The Winston logger in
/backend/src/services/logger.ts(or wherever it is configured) does not have log rotation configured. In production, log files will grow indefinitely until the disk fills up and the server crashes.Current State
Winston is configured with file transports but no rotation:
A busy production server logging every request and blockchain event will generate hundreds of MB per day.
Fix
Use
winston-daily-rotate-file:Additional Steps
logs/directory to.gitignoreLOG_LEVELenvironment variablerequestId,userId,durationon every requestAcceptance Criteria
winston-daily-rotate-fileinstalled and configuredlogs/directory in.gitignoreLOG_LEVELenvironment variable respected