question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not remove old log file

See original GitHub issue
const winston = require('winston');
require('winston-daily-rotate-file');

const transport = new (winston.transports.DailyRotateFile)({
	"name": "basic-log",
	"datePattern": "YYYY-MM-DD",
	"zippedArchive": false,
	"level": "info",
	"colorize": false,
	"filename": "./logs/log-%DATE%.txt",
	"maxSize": "1m",
	"maxFiles": "10",
});

transport.on('rotate', function(oldFilename, newFilename) {
	// do something fun
	console.log(new Date(), oldFilename, newFilename)
});

const logger = new (winston.Logger)({
	transports: [
		transport
	]
});

const str = 'Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Hello World!';
setInterval(function () {
	for (let i = 0; i < 100; i++)
		logger.info(str);
}, 10);

2018-03-20T12:44:14.690Z ‘logs\log-2018-03-20.txt.4’ ‘logs\log-2018-03-20.txt.5’ 2018-03-20T12:44:15.368Z ‘logs\log-2018-03-20.txt.5’ ‘logs\log-2018-03-20.txt.6’ 2018-03-20T12:44:16.067Z ‘logs\log-2018-03-20.txt.6’ ‘logs\log-2018-03-20.txt.7’ 2018-03-20T12:44:16.751Z ‘logs\log-2018-03-20.txt.7’ ‘logs\log-2018-03-20.txt.8’ 2018-03-20T12:44:17.468Z ‘logs\log-2018-03-20.txt.8’ ‘logs\log-2018-03-20.txt.9’ 2018-03-20T12:44:18.190Z ‘logs\log-2018-03-20.txt.9’ ‘logs\log-2018-03-20.txt.10’ 2018-03-20T12:44:18.869Z ‘logs\log-2018-03-20.txt.10’ ‘logs\log-2018-03-20.txt.11’ 2018-03-20T12:44:19.590Z ‘logs\log-2018-03-20.txt.11’ ‘logs\log-2018-03-20.txt.12’ 2018-03-20T12:44:20.270Z ‘logs\log-2018-03-20.txt.12’ ‘logs\log-2018-03-20.txt.13’ 2018-03-20T12:44:20.968Z ‘logs\log-2018-03-20.txt.13’ ‘logs\log-2018-03-20.txt.14’ 2018-03-20T12:44:20.968Z '[FileStreamRotator] Could not remove old log file: ’ ‘logs\log-2018-03-20.txt.4’ 2018-03-20T12:44:21.689Z ‘logs\log-2018-03-20.txt.14’ ‘logs\log-2018-03-20.txt.15’ 2018-03-20T12:44:22.369Z ‘logs\log-2018-03-20.txt.15’ ‘logs\log-2018-03-20.txt.16’ 2018-03-20T12:44:23.069Z ‘logs\log-2018-03-20.txt.16’ ‘logs\log-2018-03-20.txt.17’ 2018-03-20T12:44:23.790Z ‘logs\log-2018-03-20.txt.17’ ‘logs\log-2018-03-20.txt.18’ 2018-03-20T12:44:24.469Z ‘logs\log-2018-03-20.txt.18’ ‘logs\log-2018-03-20.txt.19’ 2018-03-20T12:44:25.170Z ‘logs\log-2018-03-20.txt.19’ ‘logs\log-2018-03-20.txt.20’ 2018-03-20T12:44:25.870Z ‘logs\log-2018-03-20.txt.20’ ‘logs\log-2018-03-20.txt.21’ 2018-03-20T12:44:26.570Z '[FileStreamRotator] Could not remove old log file: ’ ‘logs\log-2018-03-20.txt.12’ 2018-03-20T12:44:26.570Z ‘logs\log-2018-03-20.txt.21’ ‘logs\log-2018-03-20.txt.22’ 2018-03-20T12:44:27.282Z ‘logs\log-2018-03-20.txt.22’ ‘logs\log-2018-03-20.txt.23’

and with “zippedArchive”: true no file is deleted

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:30 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
daleliciouscommented, Feb 22, 2019

Same here, “maxFiles”: “1d” doesn’t work in my end.

3reactions
theRealKhushalcommented, Nov 11, 2019

@mattberther Do we have any updates on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to delete files "Setup Log Files" - Microsoft Community
The files are no longer necessary and can safely be removed. To remove them, simply turn on the checkbox and click OK.
Read more >
Deleting older log files - shell script - Unix Stack Exchange
I need to delete older logs based on date. For example, I want only last 5 days logs and older logs should be...
Read more >
Remove Old Log Files... : Forums - PythonAnywhere
Trying to remove schedule task's old log files but getting permission denied error. There are 100+ log files @ var/log which we need...
Read more >
Why my log files are not deleted from disk when I run PRUNE ...
AND DELETE, the command takes a very long time to complete and log files are not deleted at the disk location specified by...
Read more >
Laravel logging is not deleting old log files - Reddit
Effectively, it should keep the latest X files on your disk. As to why it doesn't in your case, it could be a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found