I'm trying to follow my logs , I want to create a log folder where all the logs are organized by year/month/day format
for example:
app:
|---log
| |---2016
| | |---3
| | | |---12
| | | | |---info.log
| | | | |---error.log
| | | |---15
| | | | |---info.log
| | | | |---silly.log
| | |---5
| | | |---4
| | | | |---crit.log
| |---2017
| | |---1
| | | |---1
| | | | |---crit.log
| | | |---2
| | | | |---info.log
and so on...
I got this code :
let logger = new(winston.Logger)({
levels: {
emerg: 0,
alert: 1,
crit: 2,
error: 3,
warning: 4,
notice: 5,
info: 6,
debug: 7,
},
transports: [
new (winston.transports.File)({
name: 'info-file',
filename: './log/' + DateObj.getFullYear().toString() + '/' + DateObj.getMonth().toString() + '/' + DateObj.getDate().toString() + '/info.log',
//filename: './log/info.log',
level: 'info'
}),
new(winston.transports.Console)({
level: 'info',
//colorize: true
}),
new (winston.transports.File)({
name: 'error-file',
filename: './log/error.log',
level: 'error'
}),
]
});
When I use the 'info' level the proggram crash with the error : Error: ENOENT: no such file or directory,
what is wrong with how I build the file path ? , or is there another way (using a libary or other tools) to do this?
via Zed Evans
No comments:
Post a Comment