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

Not deleting zipped log files #380

Open
Livia-Peng opened this issue Sep 6, 2023 · 1 comment
Open

Not deleting zipped log files #380

Livia-Peng opened this issue Sep 6, 2023 · 1 comment

Comments

@Livia-Peng
Copy link

Livia-Peng commented Sep 6, 2023

We're using the Winston daily logger like so:

{
  handleExceptions: true,
  formatter: formatter,
  filename: "/logs/ezlink-%DATE%.log",
  datePattern: "YYYY-MM-DD.HH.mm",
  zippedArchive: true,
  maxSize: "20m",
  maxFiles: 5
}

However, it's not deleting old zipped log files.
I tested that not zipped files can be deleted.
image

@hyavari
Copy link

hyavari commented Jan 10, 2024

this.logStream.on('logRemoved', function (params) {
    if (options.zippedArchive) {
        var gzName = params.name + '.gz';
        if (fs.existsSync(gzName)) {
            try {
                fs.unlinkSync(gzName);
            }
            catch (_err) {
                // file is there but we got an error when trying to delete,
                // so permissions problem or concurrency issue and another
                // process already deleted it we could detect the concurrency
                // issue by checking err.type === ENOENT or EACCESS for
                // permissions ... but then?
            }
            self.emit('logRemoved', gzName);
            return;
        }
    }
    self.emit('logRemoved', params.name);
});

It seems not easy to reproduce it. But for now, disabling the archiving is simpler.

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

No branches or pull requests

2 participants