accesslog

Simple common/combined access log middleware

3 个版本
安装
npm install accesslog
yarn add accesslog
pnpm add accesslog
bun add accesslog
README

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

版本列表
0.0.2 2013-11-29
0.0.1 2012-07-22
0.0.0 2012-07-22