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

@kazunori-kimura/koa-log4js

v1.1.1

Published

logger middleware for koa

Readme

@kazunori-kimura/koa-log4js

logger middleware for koa

Install

npm install @kazunori-kimura/koa-log4js

Usage

ログ設定をJSONで渡す

const koa = require("koa");
const app = koa();
const Log = require("../index.js");

const PORT = 3000;
const logfile = `${__dirname}/app.log`;

// set log4js configuration
const log = Log({ filename: logfile }, "INFO");
// get logger instance
const logger = log.logger;

// set logging middleware
app.use(log.logging);

app.use(function* (){
  this.body = "Hello, world!";
});

app.listen(PORT);
logger.info(`listen at http://localhost:${PORT}`);

const msg = "test log.";
logger.trace(msg);
logger.debug(msg);
logger.info(msg);
logger.warn(msg);
logger.error(msg);
logger.fatal(msg);

設定ファイルを使用

config.json

{
  "appenders": [
    {
      "type": "dateFile",
      "category": "test",
      "filename": "test/system.log",
      "pattern": "-yyyy-MM-dd"
    },
    { "type": "console" }
  ],
  "levels": { "test": "INFO" }
}

上記JSONファイルを保存し、そのパスを渡してインスタンスを取得します

const koa = require("koa");
const app = koa();
const Log = require("../index.js");

const PORT = 3000;

// set log4js configuration
const log = Log(`${__dirname}/config.json`);
// get logger instance
const logger = log.logger;

// set logging middleware
app.use(log.logging);

app.use(function* (){
  this.body = "Hello, world!";
});

app.listen(PORT);
logger.info("--- test-config.js ---");
logger.info(`listen at http://localhost:${PORT}`);

const msg = "test log.";
logger.trace(msg);
logger.debug(msg);
logger.info(msg);
logger.warn(msg);
logger.error(msg);
logger.fatal(msg);

設定ファイルについて

appenders に複数の設定を記載した場合、使用されるのは先頭に記載した appender になります。

LICENSE

MIT