1.0.10 • Published 6 years ago

koa-log4js-logger v1.0.10

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

koa-log4js

Koa Log4js Middleware

Dependences

Installation

$ npm install koa-log4js-logger

Usage

const Koa = require('koa')
const logger = require('koa-log4js-logger')
const app = new Koa()
app.use(logger(app))

// response
app.use(ctx => {
  ctx.log.info('Hello Koa')
  ctx.body = 'Hello Koa';
})

if (!module.parent) {
  const port = process.env.PORT || '3000'
  app.listen(port)
  app.log.info('Listening on ' + port)
}

Notes

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

Custom Production Configure

app.use(logger(app, {
  access: { // access log
    'type': 'dateFile',
    'filename': 'logs/access.log',
    'daysToKeep': 10,
    'pattern': '.yyyy-MM-dd'
  },
  app: { // app log
    'type': 'file',
    'filename': 'logs/app.log',
    'maxLogSize': 10485760,
    'numBackups': 3,
  },
  error: { // error log
    'type': 'file',
    'filename': 'logs/errors.log',
  }
}))

License

MIT

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago