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

When does it start zipping logs? #108

Closed
ghost opened this issue Nov 9, 2017 · 7 comments
Closed

When does it start zipping logs? #108

ghost opened this issue Nov 9, 2017 · 7 comments
Labels

Comments

@ghost
Copy link

ghost commented Nov 9, 2017

No description provided.

@mattberther
Copy link
Member

It zips the logs after rotation. Please note that some long-overdue refactoring of the transport has occurred. A PR is available at #107. Also, a pre-release version has been published to npm. Please npm install [email protected] if you see any strangeness with the 1.x transport and zipping.

Please re-open this issue if you have further questions.

@ghost
Copy link
Author

ghost commented Nov 9, 2017

It zips after one day?

I have many .log files from months ago.

Does the application have to run continually for it to zip them up daily?

Maybe it should become a feature where, upon starting, it can detect old log files and zip them up.

@mattberther
Copy link
Member

The application will zip the log after it is rotated, assuming zippedArchive is set to true. The transport will not modify any files it does not know about, which means it will not zip up log files that were not created by the currently running process.

@ghost
Copy link
Author

ghost commented Nov 10, 2017

Is it possible to make it so that it does zip up log files that were generated by previous instances of the same app?

@mattberther
Copy link
Member

The transport will not be updated to zip up log files that the currently running process did not create. Perhaps this is something that your app can do prior to instantiating the winston logger.

@ghost
Copy link
Author

ghost commented Nov 10, 2017

Would it be possible to expose a method for zipping logs?

@mattberther
Copy link
Member

mattberther commented Nov 11, 2017

No, but your app code can zip logs using this code:

var zlib = require('zlib');
var oldFile = someMethodToRetrieveYourFile();

var gzip = zlib.createGzip();
var inp = fs.createReadStream(oldFile);
var out = fs.createWriteStream(oldFile + '.gz');
inp.pipe(gzip).pipe(out).on('finish', function () {
    fs.unlinkSync(oldFile);
});

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

No branches or pull requests

1 participant