added dailyRotateFile transport. #205

wants to merge 1 commit into


None yet
9 participants

matsukaz commented Dec 18, 2012

I've added dailyRotateFile transport.
It can be used as follows.

  category1: {
    dailyRotateFile: {
      colorize: 'true',
      filename: 'dailyRotateFile.log',
      datePattern: '.yyyy-MM-dd',
      maxsize: 20000

it will create a log file like "dailyRotateFile.log.2012-12-18".
you can use the following meta characters in datePattern.

  • yy
  • yyyy
  • M
  • MM
  • d
  • dd
  • H
  • HH
  • m
  • mm

Wouldn't this make sense as an option on the stock file transport? Also trivial thing but could the datePattern be inserted into the filename so the file extension remains intact?

For clarity: I'm not a decision make here - just an interested third party who would use daily log rotation if it was available.


mmalecki commented Jan 3, 2013

My opinion is that log rotation should be handled by external tools.
@AvianFlu @bmeck opinions?

@mmalecki - Winston already handles log chunking (or whatever it's called) and file size - surely this is a natural feature to add? If an external tool should handle files then we don't really need a file transport at all do we? We can just use the console transport and pipe ...

I would prefer an external tool, too. Something like logrotate will also automatically handle compression of older files, get rid of logs older than a certain amount, etc.

Any chance of getting this merged? It looks like it merges clean and multiple people have requested the feature. You can add me to the list of people that would use this.

@sebastianhoitz - it's not always possible to implement external tools e.g. when deploying via PaaS.

indexzero closed this in 49624a3 Apr 21, 2013

YoleYu commented Jun 4, 2014

cool! hope someone can add


ghost commented Dec 5, 2015

Waiting for this feature eagerly.

To solve the problem mentioned in "cluster + rotating file + large log file = crash trentm/node-bunyan#117", just add a random string to the filename.

Take the example of the thread starter:

  1. the configuration would keep the same.
  2. the log file would be changed from "dailyRotateFile.log.2012-12-18" to something like "dailyRotateFile.log.2012-12-18**.95de1c8d1a**"



indexzero commented Dec 5, 2015

This feature exists, that's why the issue is closed. Go use it 👍


ghost commented Dec 6, 2015

@indexzero OK. Thanks for the contribution. 👍

amcdnl commented Dec 18, 2015

@indexzero that winston-daily-rotate-file package didn't work for me, normal file logger did however.

is there any way to delete the old log files.?

Redsandro referenced this pull request in foreverjs/forever Jul 22, 2016


Built in logrotation #128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment