HTTP request logger middleware for koa.
morgan wrapper for koa's middleware.
$ npm install --save koa-morgan
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)
var koa = require('koa');
var morgan = require('koa-morgan');
var app = koa();
app.use(morgan.middleware(format, options));