We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cluster
Only logs from the main worker will log when using the same file
"winston": "^3.8.2", "winston-daily-rotate-file": "^4.7.1"
import 'winston-daily-rotate-file'; import cluster from 'cluster'; const { combine, timestamp, label, printf } = winston.format; const myFormat = printf(({ level, message, timestamp }) => { if (cluster.isWorker) { // Access the current cluster's worker const currentWorker = cluster.worker; return `${timestamp} ${level} [worker: ${currentWorker.process.pid}]: ${message}`; } else { return `${timestamp} ${level} : ${message}`; } }); const logTransport = new winston.transports.DailyRotateFile({ filename: 'vad-%DATE%.log', datePattern: 'YYYY-MM-DD', dirname: '/var/log/vad/', zippedArchive: true, maxSize: '20m', maxFiles: '30d', handleExceptions: true, handleRejections: true, }); export const logger = winston.createLogger({ format: winston.format.combine( winston.format.colorize(), winston.format.timestamp(), myFormat, ), transports: [logTransport] });
What is the best approach for logging in a cluster ?
v3.8.2
14
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
🔎 Search Terms
cluster
The problem
Only logs from the main worker will log when using the same file
What is the best approach for logging in a cluster ?
What version of Winston presents the issue?
v3.8.2
What version of Node are you using?
14
If this worked in a previous version of Winston, which was it?
No response
Minimum Working Example
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: