Skip to content
New issue

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

Dynamic filename in daily-rotate-file transport #483

Closed
manjuadzmedia opened this issue Oct 31, 2014 · 3 comments
Closed

Dynamic filename in daily-rotate-file transport #483

manjuadzmedia opened this issue Oct 31, 2014 · 3 comments

Comments

@manjuadzmedia
Copy link

we are trying to store logs in a minute based fashion and also want to store them hierarchically like below

/2014/05/11/errors/23/logfile1
/2014/05/11/errors/23/logfile2
..
/2014/05/11/errors/23/logfile59
/2014/05/12/errors/00/logfile1
/2014/05/12/errors/00/logfile2

and we used this code to achieve the logrotate with store files in separate hourly based files, but its not working.

var d = new Date();
var currentDate=d.getFullYear()+"/"+('0'+(d.getMonth()+1)).slice(-2)+"/"+('0'+d.getDate()).slice(-2);
var currentHour=('0'+d.getHours()).slice(-2);
var error_logger = new winston.Logger({transports: [
    new winston.transports.DailyRotateFile({
        name: 'file',
        datePattern: '.yyyy-MM-ddTHH:mm',
        filename: path.join(__dirname, currentDate+"/errors/"+currentHour, "log_file.log")
    })
],exitOnError: false});

can anyone help us, how we can achieve dynamic path???

@manjuadzmedia manjuadzmedia changed the title dynamic path [MIND BLOWING ISSUE] dynamic path Oct 31, 2014
@indexzero
Copy link
Member

There is a pull-request open for this.

@indexzero
Copy link
Member

That pull-request is #273.

@indexzero indexzero changed the title [MIND BLOWING ISSUE] dynamic path Dynamic filename in daily-rotate-file transport Dec 30, 2014
@winstonjs winstonjs locked and limited conversation to collaborators Dec 30, 2014
@indexzero
Copy link
Member

This was fixed in 0.9.0. Also worth noting that the DailyRotateFile transport was moved to a separate module (winston-daily-rotate-file) as of winston@2.0.0. Please open any new issues for DailyRotateFile in the newwinston-daily-rotate-file repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants