README.md
1.85 KB
koa-morgan
HTTP request logger middleware for koa.
morgan wrapper for koa's middleware.
Install
$ npm install --save koa-morgan
Usage
=1.x, 100%, working with morgan and koa-v2
const fs = require('fs')
const Koa = require('koa')
const morgan = require('koa-morgan')
// create a write stream (in append mode)
const accessLogStream = fs.createWriteStream(__dirname + '/access.log',
{ flags: 'a' })
const app = new Koa()
// setup the logger
app.use(morgan('combined', { stream: accessLogStream }))
app.use((ctx) => {
ctx.body = 'hello, world!'
})
app.listen(2333)
=0.x, working with koa-v1
var koa = require('koa');
var morgan = require('koa-morgan');
var app = koa();
app.use(morgan.middleware(format, options));