
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
mongo-log-rotator
Advanced tools
Library for rotating MongoDB logs on a cron-like schedule. Includes support for compression and S3 uploading.
Rotator can be used both locally on the same machine as mongo, or remotely. Most of the features are only available when running locally because it needs access to Mongo's log files.
npm install mongo-log-rotator
var Rotator = require('mongo-log-rotator');
// Every 30 seconds.
var schedule = '30 * * * * *';
var rotator = new Rotator(schedule, {
mongoURL: 'mongodb://user:pass@localhost:27017',
/* other options */
});
rotator.on('rotate', function(newFile) {
// A rotation has been completed.
// newFile is the path to the rotated log file.
});
rotator.start();
Cron scheduling is implemented using the node-cron module. The pattern documentation can be found at crontab.org.
Examples:
30 * * * * * every 30 seconds.0 0 * * * * ever hour.0 0 0 15 * * the 15th of every month.mongoURL (required): The fully qualified mongo URL. For example: mongodb://user:pass@localhost:27017.
Rotator requires admin privileges on the database to issue the logRotate command.mongoLog: If running locally (recommended), this is the full path to the mongo log file. This is required
if using the compression or s3 uploading features.autoStart: Defaults to false. Whether or not to automatically start rotating. If false, you must call
start() to begin the cron task.compress: Defaults to false. Whether or not to compress logs once they've been rotated. If enabled, the
original, uncompressed log file will be deleted once compressed.s3Upload: Defaults to false. Whether or not to upload rotated logs to s3.s3Bucket: The S3 bucket to upload log files. Required if s3Upload is enabled.awsAccessKeyID: AWS access key for uploading data to s3. Required if s3Upload is enabled.awsSecretAccessKey: AWS secret key for uploading data to s3. Required if s3Upload is enabled.autoDelete: Defaults to false. Whether or not to automatically delete rotated log files. Should be
used on conjunction with s3Upload. If the upload to S3 fails, the log file will not be deleted.Starts the Rotator cron schedule. This can be skipped if the autoStart option is enabled.
rotator.start();
Stops the Rotator cron schedule. If a rotation is currently in process, it will not be interrupted.
rotator.stop();
Occurs whenever the mongo log is rotated.
newFile (string) The path to the rotated log file.Emitted whenever an error occurs at any stage of the rotation process. Errors will not stop the rotator schedule.
err (Error) The error that occurred.Prints information about what is occurring. Useful for debugging why something may not be working.
msg (string) The debug message.FAQs
Rotates MongoDB logs using cron-like scheduling.
The npm package mongo-log-rotator receives a total of 0 weekly downloads. As such, mongo-log-rotator popularity was classified as not popular.
We found that mongo-log-rotator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.