koajs/logger

Development style logging middleware

JavaScript

559

58 commits

updated Jun 13, 2025

See the code

README

koa-logger

npm version

Development style logger middleware for koa. Compatible with request-received.

<-- GET /
--> GET / 200 835ms 746b
<-- GET /
--> GET / 200 960ms 1.9kb
<-- GET /users
--> GET /users 200 357ms 922b
<-- GET /users?page=2
--> GET /users?page=2 200 466ms 4.66kb

Installation

$ npm install koa-logger

Example

const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger())

Notes

Recommended that you .use() this middleware near the top to "wrap" all subsequent middleware.

Use Custom Transporter

const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger((str, args) => {
  // redirect koa logger to other output pipe
  // default is process.stdout(by console.log function)
}))

or

app.use(logger({
  transporter: (str, args) => {
    // ...
  }
}))

Param str is output string with ANSI Color, and you can get pure text with other modules like strip-ansi
Param args is a array by [format, method, url, status, time, length]

License

MIT

Project health

Overall

4.1/10

Maintained

0/10

Code review

2/10
OpenSSF Scorecard

Latest release

4.0.0 · Jun 13, 2025

Releases this year

0

Significant stargazers

chengchao

1,000 followers · starred Jul 2016

高云 墨智

1,514 followers · starred Nov 2016

Otto Sichert

28 followers · starred May 2018

Aleksandr Piatkin

83 followers · starred Sep 2019

koajs/logger

Development style logging middleware

JavaScript

559

58 commits

updated Jun 13, 2025

See the code

README

koa-logger

npm version

Development style logger middleware for koa. Compatible with request-received.

<-- GET /
--> GET / 200 835ms 746b
<-- GET /
--> GET / 200 960ms 1.9kb
<-- GET /users
--> GET /users 200 357ms 922b
<-- GET /users?page=2
--> GET /users?page=2 200 466ms 4.66kb

Installation

$ npm install koa-logger

Example

const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger())

Notes

Recommended that you .use() this middleware near the top to "wrap" all subsequent middleware.

Use Custom Transporter

const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger((str, args) => {
  // redirect koa logger to other output pipe
  // default is process.stdout(by console.log function)
}))

or

app.use(logger({
  transporter: (str, args) => {
    // ...
  }
}))

Param str is output string with ANSI Color, and you can get pure text with other modules like strip-ansi
Param args is a array by [format, method, url, status, time, length]

License

MIT

Project health

Overall

4.1/10

Maintained

0/10

Code review

2/10
OpenSSF Scorecard

Latest release

4.0.0 · Jun 13, 2025

Releases this year

0

Significant stargazers

chengchao

1,000 followers · starred Jul 2016

高云 墨智

1,514 followers · starred Nov 2016

Otto Sichert

28 followers · starred May 2018

Aleksandr Piatkin

83 followers · starred Sep 2019