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
Add ability for File transport to split up logs by date #10
Comments
Would accept patch request for this |
Cool! Any suggestions for an API? I was thinking something like:
but there might be some utility in allowing for a custom date / time filter. |
There is no need to complicate the winston code when there is a standard tool for this task: Logrotate (http://linuxcommand.org/man_pages/logrotate8.html) |
@indexzero Is patch for this still acceptable ? I know this can by implemented via filename option but I can add another option for this. |
it's not the task of individual daemons to each implement log rotation. this is why we have tools like logrotate, like @cemuzunlar said. |
I agree, ideally, this wouldn't be winston's problem, but
|
I see... |
++1 |
While I am also an advocate of logrotate, it does not do its work alone. Logrotate is so very usable because it provides a method to tell programs that it is time to flush and close their logs. The file transport has a _createStream.checkFile.createAndFlush function that at first glance looks like it should do the appropriate things. To use this for logrotate, have your node program trap SIGHUP and access this function. I don't have time before my dayjob to post code, but I will try tonight and post my results. Responding to SIGHUP in this fashion should be transportable to windows, and then whatever log rotation you use on windows (node library or other magic) is left as an exercise to the reader. |
In case anyone else is looking for this: Thanks for the tip, @pccowboy. I'm a big advocate of logrotate too. I'm reluctant to use one configuration for node.js service (ie winston File maxsize, etc) and another (logrotate) for other services (nginx, redis, etc) and would prefer to use logrotate for all my logfiles. I've put together a simple function which will listen to HUP signals and reopen the log file postrotate. If I get a chance, I'll try rewrite this in a cleaner manner (ie, as a configuration option for the File transport) and create a pull request. |
Fixed by #205. |
awesome! |
How to create weekly log using Winston daily rotate? |
@indexzero -
How would you feel about adding an optional API parameter to the File transport so that it can split up log files by date? The idea would be that on each new day, a new log file would be created and Winston would automatically handle all of this / know which log file to write to based on the date.
The text was updated successfully, but these errors were encountered: