npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rotating-file-stream-4js

v4.0.0

Published

log4js appender backed by rotating-file-stream.

Readme

rotating-file-stream-4js

Build Status codecov NPM version

Donate

Description

log4js appender that writes through rotating-file-stream.

Usage

import log4js from "log4js";

log4js.configure({
  appenders: {
    out: {
      type: "rotating-file-stream-4js",
      rfs: {
        filename: "file.log",
        options: { size: "10M", interval: "1d", compress: "gzip" },
        onStream: stream => {
          stream.on("rotated", console.log);
        }
      }
    }
  },
  categories: {
    default: { appenders: ["out"], level: "info" }
  }
});

const log = log4js.getLogger();
log.info("hello");

Installation

With npm:

$ npm install --save rotating-file-stream-4js

Table of contents

Configuration

The appender accepts the usual log4js appender fields, plus a required rfs object.

{
  type: "rotating-file-stream-4js",
  layout: { type: "basic" },
  timezoneOffset: 0,
  rfs: {
    filename: "file.log",
    options: { size: "10M" },
    onStream: stream => {
      stream.on("rotated", console.log);
    }
  }
}

The module object can also be passed as type (useful with bundlers):

import rotatingFileStream4js from "rotating-file-stream-4js";

log4js.configure({
  appenders: {
    out: {
      type: rotatingFileStream4js,
      rfs: {
        filename: "file.log",
        options: { size: "10M" },
        onStream: stream => {
          stream.on("rotated", console.log);
        }
      }
    }
  },
  categories: { default: { appenders: ["out"], level: "info" } }
});

rfs

Required when the appender creates the stream (type: "rotating-file-stream-4js"). Ignored when the appender comes from shareStream.

Using the same stream for more appenders

With the standard configuration each appender opens its own stream. When several appenders must write through one shared stream, use shareStream: it returns a log4js appender module bound to that stream, and each appender entry can still set its own layout and timezoneOffset.

import log4js from "log4js";
import { createStream, shareStream } from "rotating-file-stream-4js";

const stream = createStream("file.log", { size: "10M", interval: "1d" });
const shared = shareStream(stream);

stream.on("rotated", console.log);

log4js.configure({
  appenders: {
    app: {
      type: shared,
      layout: { type: "pattern", pattern: "APP %m" }
    },
    access: {
      type: shared,
      layout: { type: "pattern", pattern: "ACCESS %m" }
    }
  },
  categories: {
    default: { appenders: ["app"], level: "info" },
    access: { appenders: ["access"], level: "info" }
  }
});

Compatibility

Requires Node.js v22 and a current log4js release.

TypeScript

TypeScript types are distributed with the package itself. Everything exported by rotating-file-stream is re-exported, so a single import is enough.

License

MIT License

Bugs

Do not hesitate to report any bug or inconsistency @github.

ChangeLog

ChangeLog

Donating

If you find useful this package, please consider the opportunity to donate some satoshis to this bitcoin address: 12p1p5q7sK75tPyuesZmssiMYr4TKzpSCN