Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including koa-accesslog with all npm packages installed. Try it out:

var koaAccesslog = require("koa-accesslog")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

koa-accesslog v1.0.0

Middleware for common log format access logs

Accesslog

Output Common Log Format access logs to any stream. Defaults to process.stdout.

Install

# npm ..
npm i koa-accesslog
# yarn ..
yarn add koa-accesslog

Usage

const Koa = require('koa');
const accesslog = require('koa-accesslog');
const app = new Koa();

app.use(accesslog());

Output

127.0.0.1 - - [19/Nov/2014:13:47:37 +0100] "GET / HTTP/1.X" 404 -

Configure

You may configure Accesslog to use any writable stream such as an instance of stream.PassThrough as seen below.

const log = new stream.PassThrough();
app.use(accesslog(log));

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free