Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple common/combined access log middleware
JavaScript
Tree: d5815bcb2c

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
test
.gitignore
.travis.yml
Makefile
README.md
index.js
package.json

README.md

accesslog

Simple common/combined access log middleware

Usage

$ npm install accesslog

accesslog([options])

Creates a middleware request handler which logs requests to a file or stream in common log format.

  • options

    • stream: Stream to log to. Defaults to process.stdout.
    • path: Write log to a file at this path.
    • format: Format of log, in Apache style. Defaults to "combined" format.

Example

var accesslog = require('accesslog')()
  , http = require('http')
  , port = 3000
  ;

http.createServer(function(req, res) {
  accesslog(req, res, function() {
    var content = JSON.stringify({'hello': 'world'});
    res.writeHead(200, {'Content-Type': 'application/json', 'Content-Length': content.length});
    res.write(content);
    res.end();
  });
}).listen(port, function() {
  console.log('test server listening on port ' + port);
});

License

MIT

Something went wrong with that request. Please try again.