I am using winstonjs 3.0.0
for generating log files, I am currently using File transport for generating log files.
const file = new winston.trasnports.File({
...
filename: 'xxx.log',
maxSize: 1024
...
})
Using the code below, I get log files with names like 'xxx.log', 'xxx1.log'
.
I want to get file name with the date information when the file is created: 'YYYY-MM-DD-xxx.log'
. I considered 'winston-daily-rotate-file'
, but I do not want the log rotate within time.
Any thoughts?
Append date at the beginning of the filename like this:
let mydate = new Date();
let newFilename = mydate.getFullYear() + "-" + mydate.getMonth() + "-" + mydate.getDate() + "-" + "xxx.log";
const file = new winston.trasnports.File({
...
filename: newFilename,
maxSize: 1024
...
})