Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-daily-rotate-file

Package Overview
Dependencies
Maintainers
4
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
825K
increased by2.13%
Maintainers
4
Weekly downloads
 
Created

What is winston-daily-rotate-file?

The winston-daily-rotate-file npm package is a transport plugin for the winston logger that outputs log messages to a file, rotating the file automatically based on time, size, or both. It is commonly used to manage log files, ensuring they are kept to a manageable size and are rotated out over time for archival purposes.

What are winston-daily-rotate-file's main functionalities?

Time-based log rotation

This feature allows logs to be rotated daily. The '%DATE%' pattern in the filename is replaced with the current date in the 'YYYY-MM-DD' format. Logs older than 14 days are deleted, and logs are zipped when they are rotated.

const winston = require('winston');
const DailyRotateFile = require('winston-daily-rotate-file');

const logger = winston.createLogger({
  transports: [
    new DailyRotateFile({
      filename: 'application-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      zippedArchive: true,
      maxSize: '20m',
      maxFiles: '14d'
    })
  ]
});

Size-based log rotation

This feature allows logs to be rotated when they reach a certain size. In this example, the log file is rotated when it reaches 20 megabytes. The 'maxFiles' option is set to 5, which means that a maximum of 5 rotated log files will be kept.

const winston = require('winston');
const DailyRotateFile = require('winston-daily-rotate-file');

const logger = winston.createLogger({
  transports: [
    new DailyRotateFile({
      filename: 'application-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      zippedArchive: true,
      maxSize: '20m',
      maxFiles: '5'
    })
  ]
});

Customizable file compression

This feature allows the rotated log files to be compressed using gzip. The 'zippedArchive' option is set to true, enabling this functionality.

const winston = require('winston');
const DailyRotateFile = require('winston-daily-rotate-file');

const logger = winston.createLogger({
  transports: [
    new DailyRotateFile({
      filename: 'application-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      zippedArchive: true
    })
  ]
});

Other packages similar to winston-daily-rotate-file

Keywords

FAQs

Package last updated on 09 Feb 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc